UNPKG

1.71 kBJavaScriptView Raw
1Prism.languages.wiki = Prism.languages.extend('markup', {
2 'block-comment': {
3 pattern: /(^|[^\\])\/\*[\s\S]*?\*\//,
4 lookbehind: true,
5 alias: 'comment'
6 },
7 'heading': {
8 pattern: /^(=+).+?\1/m,
9 inside: {
10 'punctuation': /^=+|=+$/,
11 'important': /.+/
12 }
13 },
14 'emphasis': {
15 // TODO Multi-line
16 pattern: /('{2,5}).+?\1/,
17 inside: {
18 'bold italic': {
19 pattern: /(''''').+?(?=\1)/,
20 lookbehind: true
21 },
22 'bold': {
23 pattern: /(''')[^'](?:.*?[^'])?(?=\1)/,
24 lookbehind: true
25 },
26 'italic': {
27 pattern: /('')[^'](?:.*?[^'])?(?=\1)/,
28 lookbehind: true
29 },
30 'punctuation': /^''+|''+$/
31 }
32 },
33 'hr': {
34 pattern: /^-{4,}/m,
35 alias: 'punctuation'
36 },
37 'url': [
38 /ISBN +(?:97[89][ -]?)?(?:\d[ -]?){9}[\dx]\b|(?:RFC|PMID) +\d+/i,
39 /\[\[.+?\]\]|\[.+?\]/
40 ],
41 'variable': [
42 /__[A-Z]+__/,
43 // FIXME Nested structures should be handled
44 // {{formatnum:{{#expr:{{{3}}}}}}}
45 /\{{3}.+?\}{3}/,
46 /\{\{.+?\}\}/
47 ],
48 'symbol': [
49 /^#redirect/im,
50 /~{3,5}/
51 ],
52 // Handle table attrs:
53 // {|
54 // ! style="text-align:left;"| Item
55 // |}
56 'table-tag': {
57 pattern: /((?:^|[|!])[|!])[^|\r\n]+\|(?!\|)/m,
58 lookbehind: true,
59 inside: {
60 'table-bar': {
61 pattern: /\|$/,
62 alias: 'punctuation'
63 },
64 rest: Prism.languages.markup['tag'].inside
65 }
66 },
67 'punctuation': /^(?:\{\||\|\}|\|-|[*#:;!|])|\|\||!!/m
68});
69
70Prism.languages.insertBefore('wiki', 'tag', {
71 // Prevent highlighting inside <nowiki>, <source> and <pre> tags
72 'nowiki': {
73 pattern: /<(nowiki|pre|source)\b[\s\S]*?>[\s\S]*?<\/\1>/i,
74 inside: {
75 'tag': {
76 pattern: /<(?:nowiki|pre|source)\b[\s\S]*?>|<\/(?:nowiki|pre|source)>/i,
77 inside: Prism.languages.markup['tag'].inside
78 }
79 }
80 }
81});