source: node_modules/refractor/lang/wiki.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

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