]>
luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/asciidoc.js
1 /*! `asciidoc` grammar compiled for Highlight.js 11.11.1 */
3 var hljsGrammar
= (function () {
9 Author: Dan Allen <dan.j.allen@gmail.com>
10 Website: http://asciidoc.org
11 Description: A semantic, text-based document format that can be exported to HTML, DocBook and other backends.
15 /** @type LanguageFn */
16 function asciidoc(hljs
) {
17 const regex
= hljs
.regex
;
18 const HORIZONTAL_RULE
= {
19 begin: '^\'{3,}[ \\t]*$',
22 const ESCAPED_FORMATTING
= [
23 // escaped constrained formatting marks (i.e., \* \_ or \`)
25 // escaped unconstrained formatting marks (i.e., \\** \\__ or \\``)
26 // must ignore until the next formatting marks
27 // this rule might not be 100% compliant with Asciidoctor 2.0 but we are entering undefined behavior territory...
28 { begin: /\\\\\*{2}[^\n]*?\*{2}/ },
29 { begin: /\\\\_{2}[^\n]*_{2}/ },
30 { begin: /\\\\`{2}[^\n]*`{2}/ },
31 // guard: constrained formatting mark may not be preceded by ":", ";" or
32 // "}". match these so the constrained rule doesn't see them
33 { begin: /[:;}][*_`](?![*_`])/ }
36 // inline unconstrained strong (single line)
39 begin: /\*{2}([^\n]+?)\*{2}/
41 // inline unconstrained strong (multi-line)
46 /((\*(?!\*)|\\[^\n]|[^*\n\\])+\n)+/,
47 /(\*(?!\*)|\\[^\n]|[^*\n\\])*/,
52 // inline constrained strong (single line)
55 // must not precede or follow a word character
56 begin: /\B\*(\S|\S[^\n]*?\S)\*(?!\w)/
58 // inline constrained strong (multi-line)
61 // must not precede or follow a word character
62 begin: /\*[^\s]([^\n]+\n)+([^\n]+)\*/
66 // inline unconstrained emphasis (single line)
68 className: 'emphasis',
69 begin: /_{2}([^\n]+?)_{2}/
71 // inline unconstrained emphasis (multi-line)
73 className: 'emphasis',
76 /((_(?!_)|\\[^\n]|[^_\n\\])+\n)+/,
77 /(_(?!_)|\\[^\n]|[^_\n\\])*/,
82 // inline constrained emphasis (single line)
84 className: 'emphasis',
85 // must not precede or follow a word character
86 begin: /\b_(\S|\S[^\n]*?\S)_(?!\w)/
88 // inline constrained emphasis (multi-line)
90 className: 'emphasis',
91 // must not precede or follow a word character
92 begin: /_[^\s]([^\n]+\n)+([^\n]+)_/
94 // inline constrained emphasis using single quote (legacy)
96 className: 'emphasis',
97 // must not follow a word character or be followed by a single quote or space
98 begin: '\\B\'(?![\'\\s])',
100 // allow escaped single quote followed by word char
112 begin: '^(NOTE|TIP|IMPORTANT|WARNING|CAUTION):\\s+',
115 const BULLET_LIST
= {
117 begin: '^(\\*+|-+|\\.+|[^\\n]+?::)\\s+'
128 // can also be done as...
144 // example, admonition & sidebar blocks
146 begin: '^[=\\*]{4,}\\n',
147 end: '\\n^[=\\*]{4,}$',
152 className: 'section',
155 { begin: '^(={1,6})[ \t].+?([ \t]\\1)?$' },
156 { begin: '^[^\\[\\]\\n]+?\\n[=\\-~\\^\\+]{2,}$' }
159 // document attributes
170 begin: '^\\[.+?\\]$',
180 // listing and literal blocks
183 begin: '^[\\-\\.]{4,}\\n',
184 end: '\\n[\\-\\.]{4,}$',
187 // passthrough blocks
189 begin: '^\\+{4,}\\n',
204 ...ESCAPED_FORMATTING
,
208 // inline smart quotes
212 { begin: "``.+?''" },
216 // inline unconstrained emphasis
222 // inline code snippets (TODO should get same treatment as strong and emphasis)
225 begin: '(`.+?`|\\+.+?\\+)',
228 // indented literal block
238 begin: '(link:)?(http|https|ftp|file|irc|image:?):\\S+?\\[[^[]*?\\]',
242 begin: '(link|image:?):',
270 hljs
.registerLanguage('asciidoc', hljsGrammar
);