diff options
| author | Michal Nazarewicz | 2018-03-31 14:16:54 +0100 |
|---|---|---|
| committer | Michal Nazarewicz | 2018-04-07 11:16:12 +0100 |
| commit | 8d3bb7beb4bfab60ba31505728f8f945116d7a40 (patch) | |
| tree | c8bea63e9079c07dd69193ac3cf6ddaf6af1d7d3 /test | |
| parent | 358da4565b589570759ddc9c2d1043405fdbb26e (diff) | |
| download | emacs-8d3bb7beb4bfab60ba31505728f8f945116d7a40.tar.gz 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')
| -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." | |||
| 131 | (sgml-delete-tag 1) | 131 | (sgml-delete-tag 1) |
| 132 | (should (string= "Winter is comin'" (buffer-string))))) | 132 | (should (string= "Winter is comin'" (buffer-string))))) |
| 133 | 133 | ||
| 134 | (ert-deftest sgml-quote-works () | ||
| 135 | (let ((text "Foo<Bar> \"Baz\" 'Qux'\n")) | ||
| 136 | (with-temp-buffer | ||
| 137 | ;; Back and forth transformation. | ||
| 138 | (insert text) | ||
| 139 | (sgml-quote (point-min) (point-max)) | ||
| 140 | (should (string= "Foo<Bar> "Baz" 'Qux'\n" | ||
| 141 | (buffer-string))) | ||
| 142 | (sgml-quote (point-min) (point-max) t) | ||
| 143 | (should (string= text (buffer-string))) | ||
| 144 | |||
| 145 | ;; The same text escaped differently. | ||
| 146 | (erase-buffer) | ||
| 147 | (insert "Foo<Bar> "Baz" 'Qux'\n") | ||
| 148 | (sgml-quote (point-min) (point-max) t) | ||
| 149 | (should (string= text (buffer-string))) | ||
| 150 | |||
| 151 | ;; Lack of semicolon. | ||
| 152 | (erase-buffer) | ||
| 153 | (insert "&&") | ||
| 154 | (sgml-quote (point-min) (point-max) t) | ||
| 155 | (should (string= "&&" (buffer-string))) | ||
| 156 | |||
| 157 | ;; Double quoting | ||
| 158 | (sgml-quote (point-min) (point-max)) | ||
| 159 | (sgml-quote (point-min) (point-max)) | ||
| 160 | (sgml-quote (point-min) (point-max) t) | ||
| 161 | (sgml-quote (point-min) (point-max) t) | ||
| 162 | (should (string= "&&" (buffer-string)))))) | ||
| 163 | |||
| 134 | (provide 'sgml-mode-tests) | 164 | (provide 'sgml-mode-tests) |
| 135 | ;;; sgml-mode-tests.el ends here | 165 | ;;; sgml-mode-tests.el ends here |