[PATCH] XSLScript: added CDATA support
Maxim Dounin
mdounin at mdounin.ru
Sun Apr 14 20:15:08 UTC 2024
# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1713125471 -10800
# Sun Apr 14 23:11:11 2024 +0300
# Node ID cc0402def1f9c4c8a8089cb2d8ad7795dd17668b
# Parent 01dc9ba12e1ba472f22d6f1be3eaa3c2b4f2879e
XSLScript: added CDATA support.
Notably, this simplifies adding javascript code to templates, which otherwise
require complex escaping.
Requested by Igor Sysoev.
diff --git a/xslscript.pl b/xslscript.pl
--- 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
More information about the nginx-devel
mailing list