Skip to content

Commit

Permalink
Relax markup grammar to allow non-ASCII chars in tag names and attrib…
Browse files Browse the repository at this point in the history
…utes. Fix #585
  • Loading branch information
Golmote committed Jun 12, 2015
1 parent 534f34c commit 52fd55e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
10 changes: 5 additions & 5 deletions components/prism-markup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ Prism.languages.markup = {
'doctype': /<!DOCTYPE.+?>/,
'cdata': /<!\[CDATA\[[\w\W]*?]]>/i,
'tag': {
pattern: /<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/i,
pattern: /<\/?[^\s>\/]+\s*(?:\s+[^\s>\/=]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/i,
inside: {
'tag': {
pattern: /^<\/?[\w:-]+/i,
pattern: /^<\/?[^\s>\/]+/i,
inside: {
'punctuation': /^<\/?/,
'namespace': /^[\w-]+?:/
'namespace': /^[^\s>\/:]+:/
}
},
'attr-value': {
Expand All @@ -21,9 +21,9 @@ Prism.languages.markup = {
},
'punctuation': /\/?>/,
'attr-name': {
pattern: /[\w:-]+/,
pattern: /[^\s>\/]+/,
inside: {
'namespace': /^[\w-]+?:/
'namespace': /^[^\s>\/:]+:/
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/prism-markup.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion examples/prism-markup.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,9 @@ <h2>Invalid HTML</h2>
<h2>Multi-line attribute values</h2>
<pre><code>&lt;p title="foo
bar
baz"></code></pre>
baz"></code></pre>

<h2>XML tags with non-ASCII characters</h2>
<pre><code>&lt;L&auml;ufer&gt;foo&lt;/L&auml;ufer&gt;
&lt;tag l&auml;ufer="l&auml;ufer"&gt;bar&lt;/tag&gt;
&lt;l&auml;ufer:tag&gt;baz&lt;/l&auml;ufer:tag&gt;</code></pre>
10 changes: 5 additions & 5 deletions prism.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,13 @@ Prism.languages.markup = {
'doctype': /<!DOCTYPE.+?>/,
'cdata': /<!\[CDATA\[[\w\W]*?]]>/i,
'tag': {
pattern: /<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/i,
pattern: /<\/?[^\s>\/]+\s*(?:\s+[^\s>\/=]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/i,
inside: {
'tag': {
pattern: /^<\/?[\w:-]+/i,
pattern: /^<\/?[^\s>\/]+/i,
inside: {
'punctuation': /^<\/?/,
'namespace': /^[\w-]+?:/
'namespace': /^[^\s>\/:]+:/
}
},
'attr-value': {
Expand All @@ -458,9 +458,9 @@ Prism.languages.markup = {
},
'punctuation': /\/?>/,
'attr-name': {
pattern: /[\w:-]+/,
pattern: /[^\s>\/]+/,
inside: {
'namespace': /^[\w-]+?:/
'namespace': /^[^\s>\/:]+:/
}
}

Expand Down

0 comments on commit 52fd55e

Please sign in to comment.