Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add patch to support <% %> blocks in XML mode, from http://platypope.…

…org/blog/2006/9/1/more-valid-than-you

darcs-hash:20070403102750-6ba2e-f91218d6282ce12533cac27632a6642c36417def.gz
  • Loading branch information...
commit a77629d6a3130d710386e0553a1cbb640797c7e3 1 parent 012f1bc
Steve Purcell authored
Showing with 14 additions and 0 deletions.
  1. +14 −0 site-lisp/nxml-mode/xmltok.el
14 site-lisp/nxml-mode/xmltok.el
View
@@ -496,6 +496,9 @@ as special. Return the type of the token."
(xmltok+ (xmltok-g markup-declaration "!")
(xmltok-g comment-first-dash "-"
(xmltok-g comment-open "-") opt) opt))
+ (erb-section
+ (xmltok+ "%"
+ (xmltok-g erb-section-open "[^%]") opt))
(cdata-section
(xmltok+ "!"
(xmltok-g marked-section-open "\\[")
@@ -526,6 +529,7 @@ as special. Return the type of the token."
;; by default
or cdata-section
or comment
+ or erb-section
or processing-instruction))
(xmltok-defregexp
xmltok-attribute
@@ -693,6 +697,16 @@ as special. Return the type of the token."
nil
"]]>")
'not-well-formed)))
+ ((xmltok-after-lt start erb-section-open)
+ (setq xmltok-type
+ (if (re-search-forward "[^%]%>" nil t)
+ 'erb-section
+ (xmltok-add-error "No closing %>")
+ (xmltok-add-dependent 'xmltok-unclosed-reparse-p
+ nil
+ nil
+ "%>")
+ 'not-well-formed)))
((xmltok-after-lt start processing-instruction-question)
(xmltok-scan-after-processing-instruction-open))
((xmltok-after-lt start comment-open)

6 comments on commit a77629d

Dmitry Gutov

This patch looks quite old. Do you know if it was submitted to nxml core, wherever that is?

sgml-mode has been doing something similar for at least 5 years now, only it calls these JSP tags.

Steve Purcell
Owner

Yes, it's old. See the commit comment for the original source. I don't know if it was ever submitted to nxml core, but it isn't in the official distribution, or the version which was merged into the Emacs standard lib in 2007. I should search for "jsp" in the nxml source...

Dmitry Gutov

The original source 404s for me, so I guessed the patch might be older than 2006.
I'll ask around at the mailing list.

Steve Purcell
Owner

Yeah -- it's really a huge hack. The parser is a big bunch of compile-time macro code, so extending it at runtime isn't really feasible. It's also arguably inappropriate to make nxml report as valid anything other than valid XML. :-)

Dmitry Gutov

Useful beats appropriate, if you ask me. :) I mentioned sgml-mode because it apparently was considered appropriate there.
By the way, does this hack support ERB tags inside "proper" tags? Like <p class="<%= boo %>"></p>.

Steve Purcell
Owner

I like that philosophy!

The hack does not seem to support ERB inside tags, but I would guess that it might be relatively straightforward to add...

Please sign in to comment.
Something went wrong with that request. Please try again.