Skip to content

Commit

Permalink
Textile: Regexp optimisation + don't use captures if not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
Golmote committed Oct 22, 2017
1 parent f0b8a33 commit 08139ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions components/prism-textile.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@

// *bold*, **bold**
'bold': {
pattern: RegExp('((^\\*\\*?)(?:' + modifierRegex + ')?).+?(?=\\2)'),
pattern: RegExp('(^(\\*\\*?)(?:' + modifierRegex + ')?).+?(?=\\2)'),
lookbehind: true
},

// _italic_, __italic__
'italic': {
pattern: RegExp('((^__?)(?:' + modifierRegex + ')?).+?(?=\\2)'),
pattern: RegExp('(^(__?)(?:' + modifierRegex + ')?).+?(?=\\2)'),
lookbehind: true
},

Expand Down Expand Up @@ -217,7 +217,7 @@

// Prism(C)
'mark': {
pattern: /\b\((TM|R|C)\)/,
pattern: /\b\((?:TM|R|C)\)/,
alias: 'comment',
inside: {
'punctuation':/[()]/
Expand All @@ -237,7 +237,7 @@
};

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

// Allow some nesting
Prism.languages.textile['phrase'].inside['inline'].inside['bold'].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.

0 comments on commit 08139ad

Please sign in to comment.