Skip to content

Commit

Permalink
Allow for dots in Markup tag names, but not in HTML tags included in …
Browse files Browse the repository at this point in the history
…Textile. Fixes #888
  • Loading branch information
Golmote committed Jul 3, 2016
1 parent 65619f7 commit 31ea66b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion components/prism-markup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Prism.languages.markup = {
'doctype': /<!DOCTYPE[\w\W]+?>/,
'cdata': /<!\[CDATA\[[\w\W]*?]]>/i,
'tag': {
pattern: /<\/?(?!\d)[^\s>\/=.$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,
pattern: /<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,
inside: {
'tag': {
pattern: /^<\/?[^\s>\/]+/i,
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.

3 changes: 3 additions & 0 deletions components/prism-textile.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@
'mark': Prism.util.clone(Prism.languages.textile['phrase'].inside['mark'])
};

// Only allow alpha-numeric HTML tags, not XML tags
Prism.languages.textile.tag.pattern = /<\/?(?!\d)[a-z0-9]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i;

// Allow some nesting
Prism.languages.textile['phrase'].inside['inline'].inside['bold'].inside = nestedPatterns;
Prism.languages.textile['phrase'].inside['inline'].inside['italic'].inside = nestedPatterns;
Expand Down
2 changes: 1 addition & 1 deletion components/prism-textile.min.js

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

2 changes: 1 addition & 1 deletion prism.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ Prism.languages.markup = {
'doctype': /<!DOCTYPE[\w\W]+?>/,
'cdata': /<!\[CDATA\[[\w\W]*?]]>/i,
'tag': {
pattern: /<\/?(?!\d)[^\s>\/=.$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,
pattern: /<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,
inside: {
'tag': {
pattern: /^<\/?[^\s>\/]+/i,
Expand Down
18 changes: 18 additions & 0 deletions tests/languages/markup/issue888.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<android.support.v7.widget.CardView>

----------------------------------------------------

[
["tag", [
["tag", [
["punctuation", "<"],
"android.support.v7.widget.CardView"
]],
["punctuation", ">"]
]]
]

----------------------------------------------------

Checks for tag names containing dots.
See #888 for details.

0 comments on commit 31ea66b

Please sign in to comment.