Skip to content

Commit

Permalink
Highlight all on attributes as javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
FIameCaster committed May 2, 2024
1 parent ab15799 commit c333b81
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions package/src/prism/languages/markup.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ var addInlined = (tagName, lang) => ({
'included-cdata': {
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
inside: addLang({
cdata: /^<!\[CDATA\[|\]\]>$/i
'cdata': /^<!\[CDATA\[|\]\]>$/i
}, lang)
}
}, lang)
});

var addAttribute = (attrName, lang) => ({
pattern: RegExp(`((?:^|["'\\s])(?:${attrName})\\s*=\\s*)(?:"[^"]*"|'[^']*'|[^\\s"'=]+)`, 'i'),
pattern: RegExp(`((?:^|["'\\s])(?:${attrName})\\s*=\\s*)(?:"[^"]*"|'[^']*'|[^\\s"'=>]+)`, 'gi'),
lookbehind: true,
greedy: true,
inside: addLang({
'punctuation': /^["']|["']$/,
}, lang)
Expand All @@ -36,7 +37,7 @@ var markup = languages.svg = languages.mathml = languages.html = languages.marku

markup.tag.inside['attr-value'].unshift(
addAttribute('style', 'css'),
addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source, 'javascript')
addAttribute(/on[a-z]+/.source, 'javascript')
);

insertBefore(markup, 'cdata', {
Expand Down

0 comments on commit c333b81

Please # to comment.