[d24f17c] | 1 | 'use strict'
|
---|
| 2 |
|
---|
| 3 | module.exports = wiki
|
---|
| 4 | wiki.displayName = 'wiki'
|
---|
| 5 | wiki.aliases = []
|
---|
| 6 | function 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 | }
|
---|