Mercurial > hg > xslscript
comparison 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 |
comparison
equal
deleted
inserted
replaced
11:01dc9ba12e1b | 12:cc0402def1f9 |
---|---|
43 | 43 |
44 startrule : <skip:""> item(s) eofile | 44 startrule : <skip:""> item(s) eofile |
45 { $return = $item{'item(s)'}; 1 } | 45 { $return = $item{'item(s)'}; 1 } |
46 | 46 |
47 item : "<!--" <commit> comment | 47 item : "<!--" <commit> comment |
48 | "<![CDATA[" <commit> cdata | |
48 | "!!" <commit> exclam_double | 49 | "!!" <commit> exclam_double |
49 | "!{" <commit> exclam_xpath | 50 | "!{" <commit> exclam_xpath |
50 | "!" name <commit> params | 51 | "!" name <commit> params |
51 { $return = [ | 52 { $return = [ |
52 "X:call-template", "name", $item{name}, [], | 53 "X:call-template", "name", $item{name}, [], |
106 # likely an artifact of our dump process | 107 # likely an artifact of our dump process |
107 | 108 |
108 comment : /((?!-->).)*/ms "-->" | 109 comment : /((?!-->).)*/ms "-->" |
109 { $return = "<!--" . $item[1] . "-->"; 1 } | 110 { $return = "<!--" . $item[1] . "-->"; 1 } |
110 | 111 |
112 # cdata, <![CDATA[ ... ]]> | |
113 | |
114 cdata : /((?!]]>).)*/ms "]]>" | |
115 { $return = "<![CDATA[" . $item[1] . "]]>"; 1 } | |
116 | |
111 # special chars: ', ", {, }, \ | 117 # special chars: ', ", {, }, \ |
112 # if used in text, they needs to be escaped with backslash | 118 # if used in text, they needs to be escaped with backslash |
113 | 119 |
114 text : quoted | unreserved | "'" | "\"" | "{" | 120 text : quoted | unreserved | "'" | "\"" | "{" |
115 quoted : "\\" special | 121 quoted : "\\" special |