Package: emacs;
Reported by: Michal Nazarewicz <mina86 <at> mina86.com>
Date: Thu, 5 Jun 2014 11:25:01 UTC
Severity: minor
Fixed in version 25.1
Done: Michal Nazarewicz <mina86 <at> mina86.com>
Bug is archived. No further changes may be made.
View this message in rfc822 format
From: Michal Nazarewicz <mina86 <at> mina86.com> To: 17699 <at> debbugs.gnu.org Subject: bug#17699: [PATCH 4/7] tildify.el: Better support for XML Date: Thu, 5 Jun 2014 13:27:33 +0200
* 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 “ ”[1], use a numeric reference for a no-break space (namely “ ”) [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 <, >, &, ' and " (meaning <, >, &, ' and " respectively). This is in contrast to HTML and even XHTML which defined a whole bunch of entities including “ ”. * 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. --- lisp/ChangeLog | 14 ++++++++++++++ lisp/textmodes/tildify.el | 7 ++++++- test/ChangeLog | 5 +++++ test/automated/tildify-tests.el | 15 ++++++++++++--- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 487e21c..c662add 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,19 @@ 2014-06-05 Michal Nazarewicz <mina86 <at> mina86.com> + * 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 “ ”[1], use a numeric reference for + a no-break space (namely “ ”) + + [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 <, >, &, ' and " (meaning <, + >, &, ' and " respectively). This is in contrast to HTML and even + XHTML which defined a whole bunch of entities including “ ”. + * textmodes/tildify.el (tildify-pattern-alist) (tildify-string-alist, tildify-ignored-environments-alist): Improve defcustom's types by adding more tags explaining what each diff --git a/lisp/textmodes/tildify.el b/lisp/textmodes/tildify.el index d61998a..6dd471d 100644 --- a/lisp/textmodes/tildify.el +++ b/lisp/textmodes/tildify.el @@ -90,8 +90,9 @@ mode, the item for the mode SYMBOL is looked up in the alist instead." (tex-mode . latex-mode) (plain-tex-mode . latex-mode) (sgml-mode . " ") - (xml-mode . sgml-mode) (html-mode . sgml-mode) + (xml-mode . " ") ; XML does not define , use numeric reference + (nxml-mode . xml-mode) (t . " ")) "Alist specifying what is a hard space in the current major mode. @@ -149,6 +150,10 @@ mode, the item for the mode SYMBOL is looked up in the alist instead." ("<! *--" . "-- *>") ("<" . ">")) (sgml-mode . html-mode) + (xml-mode + ("<! *--" . "-- *>") + ("<" . ">")) + (nxml-mode . xml-mode) (t nil)) "Alist specifying ignored structured text environments. Parts of text defined in this alist are skipped without performing hard space diff --git a/test/ChangeLog b/test/ChangeLog index 93ef098..38a4feb 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,5 +1,10 @@ 2014-06-05 Michal Nazarewicz <mina86 <at> mina86.com> + * 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 6fee28b..dd404fc 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 " "))) + (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. -- 2.0.0.526.g5318336
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.