File tree Expand file tree Collapse file tree 1 file changed +16
-22
lines changed Expand file tree Collapse file tree 1 file changed +16
-22
lines changed Original file line number Diff line number Diff line change 1- import { insertBefore } from '../util/language-util.js' ;
21import markup from './markup.js' ;
32
43/** @type {import('../types.d.ts').LanguageProto<'wiki'> } */
54export default {
65 id : 'wiki' ,
76 base : markup ,
87 grammar ( { base } ) {
9- const tag = /** @type {GrammarToken } */ ( base [ 'tag' ] ) ;
8+ const tag = /** @type {import('../types.d.ts'). GrammarToken } */ ( base [ 'tag' ] ) ;
109
11- insertBefore ( base , 'tag' , {
12- // Prevent highlighting inside <nowiki>, <source> and <pre> tags
13- 'nowiki' : {
14- pattern : / < ( n o w i k i | p r e | s o u r c e ) \b [ ^ > ] * > [ \s \S ] * ?< \/ \1> / i,
15- inside : {
16- 'tag' : {
17- pattern : / < (?: n o w i k i | p r e | s o u r c e ) \b [ ^ > ] * > | < \/ (?: n o w i k i | p r e | s o u r c e ) > / i,
18- inside : tag . inside ,
19- } ,
20- } ,
21- } ,
22- } ) ;
23-
24- return /** @type {Grammar } */ ( {
10+ return {
2511 'block-comment' : {
2612 pattern : / ( ^ | [ ^ \\ ] ) \/ \* [ \s \S ] * ?\* \/ / ,
2713 lookbehind : true ,
@@ -86,11 +72,19 @@ export default {
8672 } ,
8773 } ,
8874 'punctuation' : / ^ (?: \{ \| | \| \} | \| - | [ * # : ; ! | ] ) | \| \| | ! ! / m,
89- } ) ;
75+ $insert : {
76+ // Prevent highlighting inside <nowiki>, <source> and <pre> tags
77+ 'nowiki' : {
78+ $before : 'tag' ,
79+ pattern : / < ( n o w i k i | p r e | s o u r c e ) \b [ ^ > ] * > [ \s \S ] * ?< \/ \1> / i,
80+ inside : {
81+ 'tag' : {
82+ pattern : / < (?: n o w i k i | p r e | s o u r c e ) \b [ ^ > ] * > | < \/ (?: n o w i k i | p r e | s o u r c e ) > / i,
83+ inside : tag . inside ,
84+ } ,
85+ } ,
86+ } ,
87+ } ,
88+ } ;
9089 } ,
9190} ;
92-
93- /**
94- * @typedef {import('../types.d.ts').Grammar } Grammar
95- * @typedef {import('../types.d.ts').GrammarToken } GrammarToken
96- */
You can’t perform that action at this time.
0 commit comments