Added support for BBCode (#2095)

This adds support for the BBCode markup language.
This commit is contained in:
Michael Schmidt 2019-10-25 21:12:20 +02:00 committed by GitHub
parent ee7fdbee29
commit aaf13aa690
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 293 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@ -160,6 +160,10 @@
"title": "Batch",
"owner": "Golmote"
},
"bbcode": {
"title": "BBcode",
"owner": "RunDevelopment"
},
"bison": {
"title": "Bison",
"require": "c",

View File

@ -0,0 +1,27 @@
Prism.languages.bbcode = {
'tag': {
pattern: /\[\/?[^\s=\]]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'"\]=]+))?(?:\s+[^\s=\]]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'"\]=]+))*\s*\]/,
inside: {
'tag': {
pattern: /^\[\/?[^\s=\]]+/,
inside: {
'punctuation': /^\[\/?/
}
},
'attr-value': {
pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'"\]=]+)/i,
inside: {
'punctuation': [
/^=/,
{
pattern: /^(\s*)["']|["']$/,
lookbehind: true
}
]
}
},
'punctuation': /\]/,
'attr-name': /[^\s=\]]+/
}
}
};

1
components/prism-bbcode.min.js vendored Normal file
View File

@ -0,0 +1 @@
Prism.languages.bbcode={tag:{pattern:/\[\/?[^\s=\]]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'"\]=]+))?(?:\s+[^\s=\]]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'"\]=]+))*\s*\]/,inside:{tag:{pattern:/^\[\/?[^\s=\]]+/,inside:{punctuation:/^\[\/?/}},"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'"\]=]+)/i,inside:{punctuation:[/^=/,{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\]/,"attr-name":/[^\s=\]]+/}}};

View File

@ -0,0 +1,21 @@
<h2>Full example</h2>
<pre><code>[list]
[*]Entry A
[*]Entry B
[/list]
[list=1]
[*]Entry 1
[*]Entry 2
[/list]
[style color="fuchsia"]Text in fuchsia[/style] or
[style color=#FF00FF]Text in fuchsia[/style] or
[color=#FF00FF]Text in fuchsia[/color]
[quote]quoted text[/quote]
[quote="author"]quoted text[/quote]
[:-)]
[url]https://en.wikipedia.org[/url]
[url=https://en.wikipedia.org]English Wikipedia[/url]</code></pre>

View File

@ -35,6 +35,7 @@
"autoit": "AutoIt",
"shell": "Bash",
"basic": "BASIC",
"bbcode": "BBcode",
"bnf": "BackusNaur form",
"rbnf": "Routing BackusNaur form",
"csharp": "C#",

View File

@ -1 +1 @@
!function(){if("undefined"!=typeof self&&self.Prism&&self.document)if(Prism.plugins.toolbar){var r={html:"HTML",xml:"XML",svg:"SVG",mathml:"MathML",css:"CSS",clike:"C-like",js:"JavaScript",abap:"ABAP",abnf:"Augmented BackusNaur form",antlr4:"ANTLR4",g4:"ANTLR4",apacheconf:"Apache Configuration",apl:"APL",aql:"AQL",arff:"ARFF",asciidoc:"AsciiDoc",adoc:"AsciiDoc",asm6502:"6502 Assembly",aspnet:"ASP.NET (C#)",autohotkey:"AutoHotkey",autoit:"AutoIt",shell:"Bash",basic:"BASIC",bnf:"BackusNaur form",rbnf:"Routing BackusNaur form",csharp:"C#",cs:"C#",dotnet:"C#",cpp:"C++",cil:"CIL",coffee:"CoffeeScript",cmake:"CMake",csp:"Content-Security-Policy","css-extras":"CSS Extras",django:"Django/Jinja2",jinja2:"Django/Jinja2","dns-zone-file":"DNS zone file","dns-zone":"DNS zone file",dockerfile:"Docker",ebnf:"Extended BackusNaur form",ejs:"EJS",etlua:"Embedded Lua templating",erb:"ERB",fsharp:"F#","firestore-security-rules":"Firestore security rules",ftl:"FreeMarker Template Language",gcode:"G-code",gdscript:"GDScript",gedcom:"GEDCOM",glsl:"GLSL",gml:"GameMaker Language",gamemakerlanguage:"GameMaker Language",graphql:"GraphQL",hs:"Haskell",hcl:"HCL",http:"HTTP",hpkp:"HTTP Public-Key-Pins",hsts:"HTTP Strict-Transport-Security",ichigojam:"IchigoJam",inform7:"Inform 7",javadoc:"JavaDoc",javadoclike:"JavaDoc-like",javastacktrace:"Java stack trace",jq:"JQ",jsdoc:"JSDoc","js-extras":"JS Extras","js-templates":"JS Templates",json:"JSON",jsonp:"JSONP",json5:"JSON5",latex:"LaTeX",tex:"TeX",context:"ConTeXt",lilypond:"LilyPond",ly:"LilyPond",emacs:"Lisp",elisp:"Lisp","emacs-lisp":"Lisp",lolcode:"LOLCODE",md:"Markdown","markup-templating":"Markup templating",matlab:"MATLAB",mel:"MEL",n1ql:"N1QL",n4js:"N4JS",n4jsd:"N4JS","nand2tetris-hdl":"Nand To Tetris HDL",nasm:"NASM",nginx:"nginx",nsis:"NSIS",objectivec:"Objective-C",ocaml:"OCaml",opencl:"OpenCL",parigp:"PARI/GP",objectpascal:"Object Pascal",pcaxis:"PC-Axis",px:"PC-Axis",php:"PHP",phpdoc:"PHPDoc","php-extras":"PHP Extras",plsql:"PL/SQL",powershell:"PowerShell",properties:".properties",protobuf:"Protocol Buffers",py:"Python",q:"Q (kdb+ database)",jsx:"React JSX",tsx:"React TSX",renpy:"Ren'py",rest:"reST (reStructuredText)","robot-framework":"Robot Framework",robot:"Robot Framework",rb:"Ruby",sas:"SAS",sass:"Sass (Sass)",scss:"Sass (Scss)","shell-session":"Shell session",solidity:"Solidity (Ethereum)",soy:"Soy (Closure Template)",sparql:"SPARQL",rq:"SPARQL","splunk-spl":"Splunk SPL",sqf:"SQF: Status Quo Function (Arma 3)",sql:"SQL",tap:"TAP",toml:"TOML",tt2:"Template Toolkit 2",trig:"TriG",ts:"TypeScript","t4-cs":"T4 Text Templates (C#)",t4:"T4 Text Templates (C#)","t4-vb":"T4 Text Templates (VB)","t4-templating":"T4 templating",vbnet:"VB.Net",vhdl:"VHDL",vim:"vim","visual-basic":"Visual Basic",vb:"Visual Basic",wasm:"WebAssembly",wiki:"Wiki markup",xeoracube:"XeoraCube",xojo:"Xojo (REALbasic)",xquery:"XQuery",yaml:"YAML",yml:"YAML"};Prism.plugins.toolbar.registerButton("show-language",function(e){var a=e.element.parentNode;if(a&&/pre/i.test(a.nodeName)){var s,t=a.getAttribute("data-language")||r[e.language]||((s=e.language)?(s.substring(0,1).toUpperCase()+s.substring(1)).replace(/s(?=cript)/,"S"):s);if(t){var o=document.createElement("span");return o.textContent=t,o}}})}else console.warn("Show Languages plugin loaded before Toolbar plugin.")}();
!function(){if("undefined"!=typeof self&&self.Prism&&self.document)if(Prism.plugins.toolbar){var r={html:"HTML",xml:"XML",svg:"SVG",mathml:"MathML",css:"CSS",clike:"C-like",js:"JavaScript",abap:"ABAP",abnf:"Augmented BackusNaur form",antlr4:"ANTLR4",g4:"ANTLR4",apacheconf:"Apache Configuration",apl:"APL",aql:"AQL",arff:"ARFF",asciidoc:"AsciiDoc",adoc:"AsciiDoc",asm6502:"6502 Assembly",aspnet:"ASP.NET (C#)",autohotkey:"AutoHotkey",autoit:"AutoIt",shell:"Bash",basic:"BASIC",bbcode:"BBcode",bnf:"BackusNaur form",rbnf:"Routing BackusNaur form",csharp:"C#",cs:"C#",dotnet:"C#",cpp:"C++",cil:"CIL",coffee:"CoffeeScript",cmake:"CMake",csp:"Content-Security-Policy","css-extras":"CSS Extras",django:"Django/Jinja2",jinja2:"Django/Jinja2","dns-zone-file":"DNS zone file","dns-zone":"DNS zone file",dockerfile:"Docker",ebnf:"Extended BackusNaur form",ejs:"EJS",etlua:"Embedded Lua templating",erb:"ERB",fsharp:"F#","firestore-security-rules":"Firestore security rules",ftl:"FreeMarker Template Language",gcode:"G-code",gdscript:"GDScript",gedcom:"GEDCOM",glsl:"GLSL",gml:"GameMaker Language",gamemakerlanguage:"GameMaker Language",graphql:"GraphQL",hs:"Haskell",hcl:"HCL",http:"HTTP",hpkp:"HTTP Public-Key-Pins",hsts:"HTTP Strict-Transport-Security",ichigojam:"IchigoJam",inform7:"Inform 7",javadoc:"JavaDoc",javadoclike:"JavaDoc-like",javastacktrace:"Java stack trace",jq:"JQ",jsdoc:"JSDoc","js-extras":"JS Extras","js-templates":"JS Templates",json:"JSON",jsonp:"JSONP",json5:"JSON5",latex:"LaTeX",tex:"TeX",context:"ConTeXt",lilypond:"LilyPond",ly:"LilyPond",emacs:"Lisp",elisp:"Lisp","emacs-lisp":"Lisp",lolcode:"LOLCODE",md:"Markdown","markup-templating":"Markup templating",matlab:"MATLAB",mel:"MEL",n1ql:"N1QL",n4js:"N4JS",n4jsd:"N4JS","nand2tetris-hdl":"Nand To Tetris HDL",nasm:"NASM",nginx:"nginx",nsis:"NSIS",objectivec:"Objective-C",ocaml:"OCaml",opencl:"OpenCL",parigp:"PARI/GP",objectpascal:"Object Pascal",pcaxis:"PC-Axis",px:"PC-Axis",php:"PHP",phpdoc:"PHPDoc","php-extras":"PHP Extras",plsql:"PL/SQL",powershell:"PowerShell",properties:".properties",protobuf:"Protocol Buffers",py:"Python",q:"Q (kdb+ database)",jsx:"React JSX",tsx:"React TSX",renpy:"Ren'py",rest:"reST (reStructuredText)","robot-framework":"Robot Framework",robot:"Robot Framework",rb:"Ruby",sas:"SAS",sass:"Sass (Sass)",scss:"Sass (Scss)","shell-session":"Shell session",solidity:"Solidity (Ethereum)",soy:"Soy (Closure Template)",sparql:"SPARQL",rq:"SPARQL","splunk-spl":"Splunk SPL",sqf:"SQF: Status Quo Function (Arma 3)",sql:"SQL",tap:"TAP",toml:"TOML",tt2:"Template Toolkit 2",trig:"TriG",ts:"TypeScript","t4-cs":"T4 Text Templates (C#)",t4:"T4 Text Templates (C#)","t4-vb":"T4 Text Templates (VB)","t4-templating":"T4 templating",vbnet:"VB.Net",vhdl:"VHDL",vim:"vim","visual-basic":"Visual Basic",vb:"Visual Basic",wasm:"WebAssembly",wiki:"Wiki markup",xeoracube:"XeoraCube",xojo:"Xojo (REALbasic)",xquery:"XQuery",yaml:"YAML",yml:"YAML"};Prism.plugins.toolbar.registerButton("show-language",function(e){var a=e.element.parentNode;if(a&&/pre/i.test(a.nodeName)){var s,t=a.getAttribute("data-language")||r[e.language]||((s=e.language)?(s.substring(0,1).toUpperCase()+s.substring(1)).replace(/s(?=cript)/,"S"):s);if(t){var o=document.createElement("span");return o.textContent=t,o}}})}else console.warn("Show Languages plugin loaded before Toolbar plugin.")}();

View File

@ -0,0 +1,237 @@
[list]
[*]Entry A
[*]Entry B
[/list]
[list=1]
[*]Entry 1
[*]Entry 2
[/list]
[style color="fuchsia"]Text in fuchsia[/style] or
[style color=#FF00FF]Text in fuchsia[/style] or
[color=#FF00FF]Text in fuchsia[/color]
[quote]quoted text[/quote]
[quote="author"]quoted text[/quote]
[:-)]
[url]https://en.wikipedia.org[/url]
[url=https://en.wikipedia.org]English Wikipedia[/url]
----------------------------------------------------
[
["tag", [
["tag", [
["punctuation", "["],
"list"
]],
["punctuation", "]"]
]],
["tag", [
["tag", [
["punctuation", "["],
"*"
]],
["punctuation", "]"]
]],
"Entry A\n ",
["tag", [
["tag", [
["punctuation", "["],
"*"
]],
["punctuation", "]"]
]],
"Entry B\n",
["tag", [
["tag", [
["punctuation", "[/"],
"list"
]],
["punctuation", "]"]
]],
["tag", [
["tag", [
["punctuation", "["],
"list"
]],
["attr-value", [
["punctuation", "="],
"1"
]],
["punctuation", "]"]
]],
["tag", [
["tag", [
["punctuation", "["],
"*"
]],
["punctuation", "]"]
]],
"Entry 1\n ",
["tag", [
["tag", [
["punctuation", "["],
"*"
]],
["punctuation", "]"]
]],
"Entry 2\n",
["tag", [
["tag", [
["punctuation", "[/"],
"list"
]],
["punctuation", "]"]
]],
["tag", [
["tag", [
["punctuation", "["],
"style"
]],
["attr-name", "color"],
["attr-value", [
["punctuation", "="],
["punctuation", "\""],
"fuchsia",
["punctuation", "\""]
]],
["punctuation", "]"]
]],
"Text in fuchsia",
["tag", [
["tag", [
["punctuation", "[/"],
"style"
]],
["punctuation", "]"]
]],
" or\n",
["tag", [
["tag", [
["punctuation", "["],
"style"
]],
["attr-name", "color"],
["attr-value", [
["punctuation", "="],
"#FF00FF"
]],
["punctuation", "]"]
]],
"Text in fuchsia",
["tag", [
["tag", [
["punctuation", "[/"],
"style"
]],
["punctuation", "]"]
]],
" or\n",
["tag", [
["tag", [
["punctuation", "["],
"color"
]],
["attr-value", [
["punctuation", "="],
"#FF00FF"
]],
["punctuation", "]"]
]],
"Text in fuchsia",
["tag", [
["tag", [
["punctuation", "[/"],
"color"
]],
["punctuation", "]"]
]],
["tag", [
["tag", [
["punctuation", "["],
"quote"
]],
["punctuation", "]"]
]],
"quoted text",
["tag", [
["tag", [
["punctuation", "[/"],
"quote"
]],
["punctuation", "]"]
]],
["tag", [
["tag", [
["punctuation", "["],
"quote"
]],
["attr-value", [
["punctuation", "="],
["punctuation", "\""],
"author",
["punctuation", "\""]
]],
["punctuation", "]"]
]],
"quoted text",
["tag", [
["tag", [
["punctuation", "[/"],
"quote"
]],
["punctuation", "]"]
]],
["tag", [
["tag", [
["punctuation", "["],
":-)"
]],
["punctuation", "]"]
]],
["tag", [
["tag", [
["punctuation", "["],
"url"
]],
["punctuation", "]"]
]],
"https://en.wikipedia.org",
["tag", [
["tag", [
["punctuation", "[/"],
"url"
]],
["punctuation", "]"]
]],
["tag", [
["tag", [
["punctuation", "["],
"url"
]],
["attr-value", [
["punctuation", "="],
"https://en.wikipedia.org"
]],
["punctuation", "]"]
]],
"English Wikipedia",
["tag", [
["tag", [
["punctuation", "[/"],
"url"
]],
["punctuation", "]"]
]]
]
----------------------------------------------------
Checks for tags.