-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Regex: Added aliases and minor improvements (#2325)
This adds a lot of aliases to the regex tokens, so themes can apply their styles. It also makes a few improvements. See the PR for more details.
- Loading branch information
1 parent
6d663b6
commit 8a72830
Showing
6 changed files
with
132 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<p>The regex languages con be used for inline regex snippets like <code>(?<number>\d+)[-_ ]\k<number></code> but it mainly adds itself to other languages such as:</p> | ||
|
||
<h2>JavaScript</h2> | ||
<pre class="language-javascript" data-dependencies="regex"><code>Prism.languages.markup = { | ||
'comment': /<!--[\s\S]*?-->/, | ||
'prolog': /<\?[\s\S]+?\?>/, | ||
'doctype': { | ||
pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i, | ||
greedy: true | ||
}, | ||
'cdata': /<!\[CDATA\[[\s\S]*?]]>/i, | ||
'tag': { | ||
pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/i, | ||
greedy: true, | ||
inside: { | ||
'tag': { | ||
pattern: /^<\/?[^\s>\/]+/i, | ||
inside: { | ||
'punctuation': /^<\/?/, | ||
'namespace': /^[^\s>\/:]+:/ | ||
} | ||
}, | ||
'attr-value': { | ||
pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/i, | ||
inside: { | ||
'punctuation': [ | ||
/^=/, | ||
{ | ||
pattern: /^(\s*)["']|["']$/, | ||
lookbehind: true | ||
} | ||
] | ||
} | ||
}, | ||
'punctuation': /\/?>/, | ||
'attr-name': { | ||
pattern: /[^\s>\/]+/, | ||
inside: { | ||
'namespace': /^[^\s>\/:]+:/ | ||
} | ||
} | ||
|
||
} | ||
}, | ||
'entity': /&#?[\da-z]{1,8};/i | ||
};</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters