aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMichal Nazarewicz <[email protected]>2014-06-05 16:41:01 +0200
committerMichal Nazarewicz <[email protected]>2014-06-05 16:41:01 +0200
commiteb54c73a9d26325f691589a0dce561b124a50c70 (patch)
tree8884efa60057746d02ad60941d6625185160f36d /test
parente01e361f93959c5a5873ac119d9e55380dbdbbaa (diff)
tildify.el: Better support for XML
* lisp/textmodes/tildify.el (tildify-string-alist) (tildify-ignored-environments-alist): Add `nxml-mode' to the list of supported modes since `xml-mode' is no longer a thing but just an alias to the former. Also include comments and insides of tags in `tildify-ignored-environments-alist' for XML modes. Finally, since XML does not define “&nbsp;”[1], use a numeric reference for a no-break space (namely “&#160;”) [1] XML specification defines only a handful of predefined entities. The list is at <http://www.w3.org/TR/REC-xml/#sec-predefined-ent> and includes only &lt;, &gt;, &amp;, &apos; and &quot; (meaning <, >, &, ' and " respectively). This is in contrast to HTML and even XHTML which defined a whole bunch of entities including “&nbsp;”. * automated/tildify-tests.el (tildify-test--example-html): Add support for generating XML code, so that… (tildify-test-xml) …test can be added to check handling of XML documents.
Diffstat (limited to 'test')
-rw-r--r--test/ChangeLog5
-rw-r--r--test/automated/tildify-tests.el15
2 files changed, 17 insertions, 3 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index 93ef0980c9..38a4feb528 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,5 +1,10 @@
2014-06-05 Michal Nazarewicz <[email protected]>
+ * automated/tildify-tests.el (tildify-test--example-html): Add support
+ for generating XML code, so that…
+ (tildify-test-xml) …test can be added to check handling of XML
+ documents.
+
* automated/tildify-tests.el (tildify-test-find-env-group-index-bug):
New test checking end-regex building when multiple environment pairs
use integers to refer to capture groups.
diff --git a/test/automated/tildify-tests.el b/test/automated/tildify-tests.el
index 6fee28b386..dd404fcac2 100644
--- a/test/automated/tildify-tests.el
+++ b/test/automated/tildify-tests.el
@@ -36,14 +36,15 @@
"consectetur adipiscing elit."))
-(defun tildify-test--example-html (sentence &optional with-nbsp)
+(defun tildify-test--example-html (sentence &optional with-nbsp is-xml)
"Return an example HTML code.
SENTENCE is placed where spaces should not be replaced with hard spaces, and
WITH-NBSP is placed where spaces should be replaced with hard spaces. If the
-latter is missing, SENTENCE will be used in all placeholder positions."
+latter is missing, SENTENCE will be used in all placeholder positions.
+If IS-XML is non-nil, <pre> tag is not treated specially."
(let ((with-nbsp (or with-nbsp sentence)))
(concat "<p>" with-nbsp "</p>\n"
- "<pre>" sentence "</pre>\n"
+ "<pre>" (if is-xml with-nbsp sentence) "</pre>\n"
"<! -- " sentence " -- >\n"
"<p>" with-nbsp "</p>\n"
"<" sentence ">\n")))
@@ -77,6 +78,14 @@ after `tildify-buffer' is run."
(tildify-test--example-html sentence sentence)
(tildify-test--example-html sentence with-nbsp))))
+(ert-deftest tildify-test-xml ()
+ "Tests tildification in an XML document"
+ (let* ((sentence (tildify-test--example-sentence " "))
+ (with-nbsp (tildify-test--example-sentence "&#160;")))
+ (tildify-test--test '(nxml-mode)
+ (tildify-test--example-html sentence sentence t)
+ (tildify-test--example-html sentence with-nbsp t))))
+
(defun tildify-test--example-tex (sentence &optional with-nbsp)
"Return an example (La)Tex code.