Skip to content
Browse files

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


  • Loading branch information...
1 parent 012f1bc commit a77629d6a3130d710386e0553a1cbb640797c7e3 @purcell committed
Showing with 14 additions and 0 deletions.
  1. +14 −0 site-lisp/nxml-mode/xmltok.el
14 site-lisp/nxml-mode/xmltok.el
@@ -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))
(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))
@@ -693,6 +697,16 @@ as special. Return the type of the token."
+ ((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-after-lt start comment-open)

6 comments on commit a77629d


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.


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...


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


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. :-)


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>.


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.