[xslscript] XSLScript: added CDATA support.
Maxim Dounin
mdounin at mdounin.ru
Sat Apr 20 14:38:08 UTC 2024
details: http://freenginx.org/hg/xslscript/rev/cc0402def1f9
branches:
changeset: 12:cc0402def1f9
user: Maxim Dounin <mdounin at mdounin.ru>
date: Sun Apr 14 23:11:11 2024 +0300
description:
XSLScript: added CDATA support.
Notably, this simplifies adding javascript code to templates, which otherwise
require complex escaping.
Requested by Igor Sysoev.
diffstat:
xslscript.pl | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diffs (23 lines):
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