all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dale <dale@codefu.org>
To: 13844@debbugs.gnu.org
Subject: bug#13844: [PATCH] Fix html-mode quotes syntax in text
Date: Thu, 28 Feb 2013 19:01:30 -0600	[thread overview]
Message-ID: <512FFDEA.6040000@codefu.org> (raw)

Hi,

	I noticed Emacs was colorizing the following sample wrong in
html-mode:

~~~~~~
<pre>
" Dangling quote makes the closing tag get highlighted as a string
</pre>
" Highlighting now fixed: <hr />

Additionally, if you have apostrophe in sgml-specials, this more common
usage will break:

Dave's bar
Now this tag will have incorrect highlighting:
<br />
~~~~~~

	I believe I've tracked this down to two problems:

1. sgml-syntax-propertize-function is already prepared to correctly set
the syntax on " (double quotes) within text, but returns "." for the
syntax-table property value.  That's not a valid value for syntax-table
propertize.  It needs to use (string-to-syntax ".").

2. sgml-syntax-propertize-function doesn't account for the fact that you
could have set ' (apostrophe) in sgml-specials, which causes apostrophe
to be set as string syntax in the syntax table, just like " is by
default.

	The patch below hopefully fixes both problems.

	I believe I have filed my copyright assignment with the FSF for
Emacs already.

	ChangeLog entry:

~~~~~~
2013-02-28  Dale Sedivec <dale@codefu.org>

	* textmodes/sgml-mode.el (sgml-syntax-propertize-function):
	Return valid syntax-table property value when converting
	quotes within text from string syntax to punctuation syntax.
	Also perform this adjustment when apostrophe (?') is in
	sgml-specials.
~~~~~~

	Patch against Git master follows.

Dale


*** /var/folders/l1/l_tpw26n35zbm0fp4x22_vjh0000kk/T//85VjC0_sgml-mode.el	2013-02-28 19:00:02.000000000 -0600
--- lisp/textmodes/sgml-mode.el	2013-02-28 18:54:52.000000000 -0600
***************
*** 312,328 ****
  
  (defconst sgml-syntax-propertize-function
    (syntax-propertize-rules
!   ;; Use the `b' style of comments to avoid interference with the -- ... --
!   ;; comments recognized when `sgml-specials' includes ?-.
!   ;; FIXME: beware of <!--> blabla <!--> !!
     ("\\(<\\)!--" (1 "< b"))
!     ("--[ \t\n]*\\(>\\)" (1 "> b"))
!     ;; Double quotes outside of tags should not introduce strings.
!     ;; Be careful to call `syntax-ppss' on a position before the one we're
!     ;; going to change, so as not to need to flush the data we just computed.
!     ("\"" (0 (if (prog1 (zerop (car (syntax-ppss (match-beginning 0))))
!                    (goto-char (match-end 0)))
!                  "."))))
    "Syntactic keywords for `sgml-mode'.")
  
  ;; internal
--- 312,335 ----
  
  (defconst sgml-syntax-propertize-function
    (syntax-propertize-rules
!    ;; Use the `b' style of comments to avoid interference with the -- ... --
!    ;; comments recognized when `sgml-specials' includes ?-.
!    ;; FIXME: beware of <!--> blabla <!--> !!
     ("\\(<\\)!--" (1 "< b"))
!    ("--[ \t\n]*\\(>\\)" (1 "> b"))
!    ;; Quotes (single or double) outside of tags should not introduce
!    ;; strings.  Be careful to call `syntax-ppss' on a position before
!    ;; the one we're going to change, so as not to need to flush the
!    ;; data we just computed.
!    ((let (string-delimiters)
!       (when (memq ?\" sgml-specials)
!         (setq string-delimiters (cons ?\" string-delimiters)))
!       (when (memq ?' sgml-specials)
!         (setq string-delimiters (cons ?' string-delimiters)))
!       (regexp-opt-charset string-delimiters))
!     (0 (if (prog1 (zerop (car (syntax-ppss (match-beginning 0))))
!              (goto-char (match-end 0)))
!            (string-to-syntax ".")))))
    "Syntactic keywords for `sgml-mode'.")
  
  ;; internal





             reply	other threads:[~2013-03-01  1:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-01  1:01 Dale [this message]
2013-03-01  3:44 ` bug#13844: [PATCH] Fix html-mode quotes syntax in text Stefan Monnier
2016-02-24  5:43   ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=512FFDEA.6040000@codefu.org \
    --to=dale@codefu.org \
    --cc=13844@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.