diff options
author | Michal Nazarewicz <mina86@mina86.com> | 2018-03-31 14:16:54 +0100 |
---|---|---|
committer | Michal Nazarewicz <mina86@mina86.com> | 2018-04-07 11:16:12 +0100 |
commit | 8d3bb7beb4bfab60ba31505728f8f945116d7a40 (patch) | |
tree | c8bea63e9079c07dd69193ac3cf6ddaf6af1d7d3 /test/lisp/textmodes/sgml-mode-tests.el | |
parent | 358da4565b589570759ddc9c2d1043405fdbb26e (diff) | |
download | emacs-8d3bb7beb4bfab60ba31505728f8f945116d7a40.tar.gz emacs-8d3bb7beb4bfab60ba31505728f8f945116d7a40.tar.bz2 emacs-8d3bb7beb4bfab60ba31505728f8f945116d7a40.zip |
Handle quotation marks and apostrophes in ‘sgml-quote’
To be able to use text in an HTML argument, quotation marks need
to be replaced with an appropriate character reference. Make
‘sgml-quote’ do that.
While at it, fix entiteis not being unquoted if they lack closing
semicolon (e.g. ‘&’) occuring at the very end of a region.
Even though unlikely, make ‘sgml-quote’ handle this scenario.
* lisp/textmodes/sgml-mode.el (sgml-quote): Handle quotation marks and
apostrophes. Match entities lacking semicolon at the end of regions.
* test/lisp/textmodes/sgml-mode-tests.el (sgml-quote-works): New test
case for ‘sgml-quote’ function.
Diffstat (limited to 'test/lisp/textmodes/sgml-mode-tests.el')
-rw-r--r-- | test/lisp/textmodes/sgml-mode-tests.el | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/lisp/textmodes/sgml-mode-tests.el b/test/lisp/textmodes/sgml-mode-tests.el index 7ca6e676c64..6c0070ccb1e 100644 --- a/test/lisp/textmodes/sgml-mode-tests.el +++ b/test/lisp/textmodes/sgml-mode-tests.el @@ -131,5 +131,35 @@ The point is set to the beginning of the buffer." (sgml-delete-tag 1) (should (string= "Winter is comin'" (buffer-string))))) +(ert-deftest sgml-quote-works () + (let ((text "Foo<Bar> \"Baz\" 'Qux'\n")) + (with-temp-buffer + ;; Back and forth transformation. + (insert text) + (sgml-quote (point-min) (point-max)) + (should (string= "Foo<Bar> "Baz" 'Qux'\n" + (buffer-string))) + (sgml-quote (point-min) (point-max) t) + (should (string= text (buffer-string))) + + ;; The same text escaped differently. + (erase-buffer) + (insert "Foo<Bar> "Baz" 'Qux'\n") + (sgml-quote (point-min) (point-max) t) + (should (string= text (buffer-string))) + + ;; Lack of semicolon. + (erase-buffer) + (insert "&&") + (sgml-quote (point-min) (point-max) t) + (should (string= "&&" (buffer-string))) + + ;; Double quoting + (sgml-quote (point-min) (point-max)) + (sgml-quote (point-min) (point-max)) + (sgml-quote (point-min) (point-max) t) + (sgml-quote (point-min) (point-max) t) + (should (string= "&&" (buffer-string)))))) + (provide 'sgml-mode-tests) ;;; sgml-mode-tests.el ends here |