Permalink
Browse files

allow charcodes like &#0A;, &, etc

  • Loading branch information...
1 parent 279f05a commit 1f145793e4b38efb806f5710873b1c2abc86195a @FROGGS committed Mar 8, 2014
Showing with 16 additions and 3 deletions.
  1. +1 −1 lib/XML.pm6
  2. +15 −2 lib/XML/Grammar.pm6
View
@@ -430,7 +430,7 @@ class XML::Element does XML::Node
for @($node<attribute>) -> $a
{
my $an = ~$a<name>;
- my $av = ~$a<value>;
+ my $av = $a<value><char>.list>>.ast.join // '';
%attribs{$an} = $av;
}
}
View
@@ -20,7 +20,20 @@ rule xmldecl {
token version { 'version' '=' '"' <value> '"' }
token encoding { 'encoding' '=' '"' <value> '"' }
-token value { <-[\"]>+ }
+
+proto token char {*}
+token char:sym<common> { <!before $*STOPPER | '&'> .+? <?before $*STOPPER | '&'> { make ~$/ } }
+token char:sym<dec> { '&#' $<dec>=[<digit>+] ';' { make $<dec>.Int.chr } }
+token char:sym<hex>{ '&#x' $<hex>=[<xdigit>+] ';' { make :16(~$<hex>).chr } }
+token char:sym<quot> { '&quot;' { make '"' } }
+token char:sym<lt> { '&lt;' { make '<' } }
+token char:sym<gt> { '&gt;' { make '>' } }
+token char:sym<apos> { '&apos;' { make "'" } }
+token char:sym<amp> { '&amp;' { make '&' } }
+token value($*STOPPER = '"') {
+ | <?before $*STOPPER>
+ | <char>+
+}
regex doctypedecl {
'<!DOCTYPE' \s+ <name> $<content>=[.*?] '>'
@@ -35,7 +48,7 @@ rule element {
}
rule attribute {
- <name> '=' '"' $<value>=[.*?] '"'
+ <name> '=' '"' <value> '"'
}
rule child {

0 comments on commit 1f14579

Please sign in to comment.