aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Berman2021-06-14 14:57:57 +0200
committerLars Ingebrigtsen2021-06-14 14:57:57 +0200
commit8f2f91f7acf5792f0dc38f8045dc0d3ffe2e4593 (patch)
tree870bf517b4aa8398bc6ce019f8830e57c93d12b4
parent31d40cab780a5a65e9bfbff590390a94921d6ee1 (diff)
downloademacs-8f2f91f7acf5792f0dc38f8045dc0d3ffe2e4593.tar.gz
emacs-8f2f91f7acf5792f0dc38f8045dc0d3ffe2e4593.zip
Fix problem in HTML with bracketed characters
* lisp/textmodes/sgml-mode.el (sgml-tag-syntax-table): Use bracket syntax for all Unicode bracket characters (bug#43941).
-rw-r--r--lisp/textmodes/sgml-mode.el15
-rw-r--r--test/lisp/textmodes/sgml-mode-tests.el27
2 files changed, 40 insertions, 2 deletions
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index d5930e82df3..fda00ec367e 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -190,8 +190,19 @@ This takes effect when first loading the `sgml-mode' library.")
190 "Syntax table used in SGML mode. See also `sgml-specials'.") 190 "Syntax table used in SGML mode. See also `sgml-specials'.")
191 191
192(defconst sgml-tag-syntax-table 192(defconst sgml-tag-syntax-table
193 (let ((table (sgml-make-syntax-table sgml-specials))) 193 (let ((table (sgml-make-syntax-table sgml-specials))
194 (dolist (char '(?\( ?\) ?\{ ?\} ?\[ ?\] ?$ ?% ?& ?* ?+ ?/)) 194 brackets)
195 (map-char-table
196 (lambda (key value)
197 (setq brackets (cons (list
198 (if (consp key)
199 (list (car key) (cdr key))
200 key)
201 value)
202 brackets)))
203 (unicode-property-table-internal 'paired-bracket))
204 (setq brackets (delete-dups (flatten-tree brackets)))
205 (dolist (char (append brackets (list ?$ ?% ?& ?* ?+ ?/)))
195 (modify-syntax-entry char "." table)) 206 (modify-syntax-entry char "." table))
196 (unless (memq ?' sgml-specials) 207 (unless (memq ?' sgml-specials)
197 ;; Avoid that skipping a tag backwards skips any "'" prefixing it. 208 ;; Avoid that skipping a tag backwards skips any "'" prefixing it.
diff --git a/test/lisp/textmodes/sgml-mode-tests.el b/test/lisp/textmodes/sgml-mode-tests.el
index 697c96c78e5..39d44e8f683 100644
--- a/test/lisp/textmodes/sgml-mode-tests.el
+++ b/test/lisp/textmodes/sgml-mode-tests.el
@@ -204,5 +204,32 @@ The point is set to the beginning of the buffer."
204 (should (= 1 (- (car (syntax-ppss (1- (point-max)))) 204 (should (= 1 (- (car (syntax-ppss (1- (point-max))))
205 (car (syntax-ppss (point-max)))))))) 205 (car (syntax-ppss (point-max))))))))
206 206
207(ert-deftest sgml-test-brackets ()
208 "Test fontification of apostrophe preceded by paired-bracket character."
209 (let (brackets results)
210 (map-char-table
211 (lambda (key value)
212 (setq brackets (cons (list
213 (if (consp key)
214 (list (car key) (cdr key))
215 key)
216 value)
217 brackets)))
218 (unicode-property-table-internal 'paired-bracket))
219 (setq brackets (delete-dups (flatten-tree brackets)))
220 (setq brackets (append brackets (list ?$ ?% ?& ?* ?+ ?/)))
221 (with-temp-buffer
222 (while brackets
223 (let ((char (string (pop brackets))))
224 (insert (concat "<p>" char "'s</p>\n"))))
225 (html-mode)
226 (font-lock-ensure (point-min) (point-max))
227 (goto-char (point-min))
228 (while (not (eobp))
229 (goto-char (next-single-char-property-change (point) 'face))
230 (let ((val (get-text-property (point) 'face)))
231 (when val
232 (should-not (eq val 'font-lock-string-face))))))))
233
207(provide 'sgml-mode-tests) 234(provide 'sgml-mode-tests)
208;;; sgml-mode-tests.el ends here 235;;; sgml-mode-tests.el ends here