From 8cf9e6a07425bdc7355757d37297ee35ef51a8ad Mon Sep 17 00:00:00 2001 From: Golmote Date: Thu, 3 Sep 2015 08:27:37 +0200 Subject: [PATCH] Wiki markup: fixed emphasis + merged some url patterns + added TODOs --- components/prism-wiki.js | 17 +++++++++-------- components/prism-wiki.min.js | 2 +- examples/prism-wiki.html | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/components/prism-wiki.js b/components/prism-wiki.js index 5ee978769a..4a5f128142 100644 --- a/components/prism-wiki.js +++ b/components/prism-wiki.js @@ -12,18 +12,19 @@ Prism.languages.wiki = Prism.languages.extend('markup', { } }, 'emphasis': { - pattern: /('{2,4}).+?\1/, + // TODO Multi-line + pattern: /('{2,5}).+?\1/, inside: { 'bold italic': { - pattern: /('''').+?(?=\1)/, + pattern: /(''''').+?(?=\1)/, lookbehind: true }, 'bold': { - pattern: /(''').+?(?=\1)/, + pattern: /(''')[^'](?:.*?[^'])?(?=\1)/, lookbehind: true }, 'italic': { - pattern: /('').+?(?=\1)/, + pattern: /('')[^'](?:.*?[^'])?(?=\1)/, lookbehind: true }, 'punctuation': /^''+|''+$/ @@ -34,13 +35,13 @@ Prism.languages.wiki = Prism.languages.extend('markup', { alias: 'punctuation' }, 'url': [ - /ISBN +(?:97[89][ -]?)?(?:\d[ -]?){9}[\dx]\b/i, - /(?:RFC|PMID) +\d+/, - /\[\[.+?\]\]/, - /\[.+?\]/ + /ISBN +(?:97[89][ -]?)?(?:\d[ -]?){9}[\dx]\b|(?:RFC|PMID) +\d+/i, + /\[\[.+?\]\]|\[.+?\]/ ], 'variable': [ /__[A-Z]+__/, + // FIXME Nested structures should be handled + // {{formatnum:{{#expr:{{{3}}}}}}} /\{{3}.+?\}{3}/, /\{\{.+?}}/ ], diff --git a/components/prism-wiki.min.js b/components/prism-wiki.min.js index 3f1bf263c7..0e7e8cccd1 100644 --- a/components/prism-wiki.min.js +++ b/components/prism-wiki.min.js @@ -1 +1 @@ -Prism.languages.wiki=Prism.languages.extend("markup",{"block-comment":{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0,alias:"comment"},heading:{pattern:/^(=+).+?\1/m,inside:{punctuation:/^=+|=+$/,important:/.+/}},emphasis:{pattern:/('{2,4}).+?\1/,inside:{"bold italic":{pattern:/('''').+?(?=\1)/,lookbehind:!0},bold:{pattern:/(''').+?(?=\1)/,lookbehind:!0},italic:{pattern:/('').+?(?=\1)/,lookbehind:!0},punctuation:/^''+|''+$/}},hr:{pattern:/^-{4,}/m,alias:"punctuation"},url:[/ISBN +(?:97[89][ -]?)?(?:\d[ -]?){9}[\dx]\b/i,/(?:RFC|PMID) +\d+/,/\[\[.+?\]\]/,/\[.+?\]/],variable:[/__[A-Z]+__/,/\{{3}.+?\}{3}/,/\{\{.+?}}/],symbol:[/^#redirect/im,/~{3,5}/],"table-tag":{pattern:/((?:^|[|!])[|!])[^|\r\n]+\|(?!\|)/m,lookbehind:!0,inside:{"table-bar":{pattern:/\|$/,alias:"punctuation"},rest:Prism.languages.markup.tag.inside}},punctuation:/^(?:\{\||\|\}|\|-|[*#:;!|])|\|\||!!/m}),Prism.languages.insertBefore("wiki","tag",{nowiki:{pattern:/<(nowiki|pre|source)\b[\w\W]*?>[\w\W]*?<\/\1>/i,inside:{tag:{pattern:/<(?:nowiki|pre|source)\b[\w\W]*?>|<\/(?:nowiki|pre|source)>/i,inside:Prism.languages.markup.tag.inside}}}}); \ No newline at end of file +Prism.languages.wiki=Prism.languages.extend("markup",{"block-comment":{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0,alias:"comment"},heading:{pattern:/^(=+).+?\1/m,inside:{punctuation:/^=+|=+$/,important:/.+/}},emphasis:{pattern:/('{2,5}).+?\1/,inside:{"bold italic":{pattern:/(''''').+?(?=\1)/,lookbehind:!0},bold:{pattern:/(''')[^'](?:.*?[^'])?(?=\1)/,lookbehind:!0},italic:{pattern:/('')[^'](?:.*?[^'])?(?=\1)/,lookbehind:!0},punctuation:/^''+|''+$/}},hr:{pattern:/^-{4,}/m,alias:"punctuation"},url:[/ISBN +(?:97[89][ -]?)?(?:\d[ -]?){9}[\dx]\b|(?:RFC|PMID) +\d+/i,/\[\[.+?\]\]|\[.+?\]/],variable:[/__[A-Z]+__/,/\{{3}.+?\}{3}/,/\{\{.+?}}/],symbol:[/^#redirect/im,/~{3,5}/],"table-tag":{pattern:/((?:^|[|!])[|!])[^|\r\n]+\|(?!\|)/m,lookbehind:!0,inside:{"table-bar":{pattern:/\|$/,alias:"punctuation"},rest:Prism.languages.markup.tag.inside}},punctuation:/^(?:\{\||\|\}|\|-|[*#:;!|])|\|\||!!/m}),Prism.languages.insertBefore("wiki","tag",{nowiki:{pattern:/<(nowiki|pre|source)\b[\w\W]*?>[\w\W]*?<\/\1>/i,inside:{tag:{pattern:/<(?:nowiki|pre|source)\b[\w\W]*?>|<\/(?:nowiki|pre|source)>/i,inside:Prism.languages.markup.tag.inside}}}}); \ No newline at end of file diff --git a/examples/prism-wiki.html b/examples/prism-wiki.html index 1ac9b17460..6cded5ef98 100644 --- a/examples/prism-wiki.html +++ b/examples/prism-wiki.html @@ -14,7 +14,7 @@

Headings

====== Header 6 ======

Bold and italic

-
''''Both bold and italic''''
+
'''''Both bold and italic'''''
 '''Only bold'''
 ''Only italic''