Mercurial > hg > xslscript
diff xslscript.pl @ 12:cc0402def1f9 default tip
XSLScript: added CDATA support.
Notably, this simplifies adding javascript code to templates, which otherwise
require complex escaping.
Requested by Igor Sysoev.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sun, 14 Apr 2024 23:11:11 +0300 |
parents | 01dc9ba12e1b |
children |
line wrap: on
line diff
--- a/xslscript.pl +++ b/xslscript.pl @@ -45,6 +45,7 @@ startrule : <skip:""> item(s) eofile { $return = $item{'item(s)'}; 1 } item : "<!--" <commit> comment + | "<![CDATA[" <commit> cdata | "!!" <commit> exclam_double | "!{" <commit> exclam_xpath | "!" name <commit> params @@ -108,6 +109,11 @@ instruction : "X:stylesheet" comment : /((?!-->).)*/ms "-->" { $return = "<!--" . $item[1] . "-->"; 1 } +# cdata, <![CDATA[ ... ]]> + +cdata : /((?!]]>).)*/ms "]]>" + { $return = "<![CDATA[" . $item[1] . "]]>"; 1 } + # special chars: ', ", {, }, \ # if used in text, they needs to be escaped with backslash