basant307/AI_Governance_Project
048
1/*2Language: AsciiDoc3Requires: xml.js4Author: Dan Allen <dan.j.allen@gmail.com>5Website: http://asciidoc.org6Description: A semantic, text-based document format that can be exported to HTML, DocBook and other backends.7Category: markup8*/9 10/** @type LanguageFn */11function asciidoc(hljs) {12 const regex = hljs.regex;13 const HORIZONTAL_RULE = {14 begin: '^\'{3,}[ \\t]*$',15 relevance: 1016 };17 const ESCAPED_FORMATTING = [18 // escaped constrained formatting marks (i.e., \* \_ or \`)19 { begin: /\\[*_`]/ },20 // escaped unconstrained formatting marks (i.e., \\** \\__ or \\``)21 // must ignore until the next formatting marks22 // this rule might not be 100% compliant with Asciidoctor 2.0 but we are entering undefined behavior territory...23 { begin: /\\\\\*{2}[^\n]*?\*{2}/ },24 { begin: /\\\\_{2}[^\n]*_{2}/ },25 { begin: /\\\\`{2}[^\n]*`{2}/ },26 // guard: constrained formatting mark may not be preceded by ":", ";" or27 // "}". match these so the constrained rule doesn't see them28 { begin: /[:;}][*_`](?![*_`])/ }29 ];30 const STRONG = [31 // inline unconstrained strong (single line)32 {33 className: 'strong',34 begin: /\*{2}([^\n]+?)\*{2}/35 },36 // inline unconstrained strong (multi-line)37 {38 className: 'strong',39 begin: regex.concat(40 /\*\*/,41 /((\*(?!\*)|\\[^\n]|[^*\n\\])+\n)+/,42 /(\*(?!\*)|\\[^\n]|[^*\n\\])*/,43 /\*\*/44 ),45 relevance: 046 },47 // inline constrained strong (single line)48 {49 className: 'strong',50 // must not precede or follow a word character51 begin: /\B\*(\S|\S[^\n]*?\S)\*(?!\w)/52 },53 // inline constrained strong (multi-line)54 {55 className: 'strong',56 // must not precede or follow a word character57 begin: /\*[^\s]([^\n]+\n)+([^\n]+)\*/58 }59 ];60 const EMPHASIS = [61 // inline unconstrained emphasis (single line)62 {63 className: 'emphasis',64 begin: /_{2}([^\n]+?)_{2}/65 },66 // inline unconstrained emphasis (multi-line)67 {68 className: 'emphasis',69 begin: regex.concat(70 /__/,71 /((_(?!_)|\\[^\n]|[^_\n\\])+\n)+/,72 /(_(?!_)|\\[^\n]|[^_\n\\])*/,73 /__/74 ),75 relevance: 076 },77 // inline constrained emphasis (single line)78 {79 className: 'emphasis',80 // must not precede or follow a word character81 begin: /\b_(\S|\S[^\n]*?\S)_(?!\w)/82 },83 // inline constrained emphasis (multi-line)84 {85 className: 'emphasis',86 // must not precede or follow a word character87 begin: /_[^\s]([^\n]+\n)+([^\n]+)_/88 },89 // inline constrained emphasis using single quote (legacy)90 {91 className: 'emphasis',92 // must not follow a word character or be followed by a single quote or space93 begin: '\\B\'(?![\'\\s])',94 end: '(\\n{2}|\')',95 // allow escaped single quote followed by word char96 contains: [97 {98 begin: '\\\\\'\\w',99 relevance: 0100 }101 ],102 relevance: 0103 }104 ];105 const ADMONITION = {106 className: 'symbol',107 begin: '^(NOTE|TIP|IMPORTANT|WARNING|CAUTION):\\s+',108 relevance: 10109 };110 const BULLET_LIST = {111 className: 'bullet',112 begin: '^(\\*+|-+|\\.+|[^\\n]+?::)\\s+'113 };114 115 return {116 name: 'AsciiDoc',117 aliases: [ 'adoc' ],118 contains: [119 // block comment120 hljs.COMMENT(121 '^/{4,}\\n',122 '\\n/{4,}$',123 // can also be done as...124 // '^/{4,}$',125 // '^/{4,}$',126 { relevance: 10 }127 ),128 // line comment129 hljs.COMMENT(130 '^//',131 '$',132 { relevance: 0 }133 ),134 // title135 {136 className: 'title',137 begin: '^\\.\\w.*$'138 },139 // example, admonition & sidebar blocks140 {141 begin: '^[=\\*]{4,}\\n',142 end: '\\n^[=\\*]{4,}$',143 relevance: 10144 },145 // headings146 {147 className: 'section',148 relevance: 10,149 variants: [150 { begin: '^(={1,6})[ \t].+?([ \t]\\1)?$' },151 { begin: '^[^\\[\\]\\n]+?\\n[=\\-~\\^\\+]{2,}$' }152 ]153 },154 // document attributes155 {156 className: 'meta',157 begin: '^:.+?:',158 end: '\\s',159 excludeEnd: true,160 relevance: 10161 },162 // block attributes163 {164 className: 'meta',165 begin: '^\\[.+?\\]$',166 relevance: 0167 },168 // quoteblocks169 {170 className: 'quote',171 begin: '^_{4,}\\n',172 end: '\\n_{4,}$',173 relevance: 10174 },175 // listing and literal blocks176 {177 className: 'code',178 begin: '^[\\-\\.]{4,}\\n',179 end: '\\n[\\-\\.]{4,}$',180 relevance: 10181 },182 // passthrough blocks183 {184 begin: '^\\+{4,}\\n',185 end: '\\n\\+{4,}$',186 contains: [187 {188 begin: '<',189 end: '>',190 subLanguage: 'xml',191 relevance: 0192 }193 ],194 relevance: 10195 },196 197 BULLET_LIST,198 ADMONITION,199 ...ESCAPED_FORMATTING,200 ...STRONG,201 ...EMPHASIS,202 203 // inline smart quotes204 {205 className: 'string',206 variants: [207 { begin: "``.+?''" },208 { begin: "`.+?'" }209 ]210 },211 // inline unconstrained emphasis212 {213 className: 'code',214 begin: /`{2}/,215 end: /(\n{2}|`{2})/216 },217 // inline code snippets (TODO should get same treatment as strong and emphasis)218 {219 className: 'code',220 begin: '(`.+?`|\\+.+?\\+)',221 relevance: 0222 },223 // indented literal block224 {225 className: 'code',226 begin: '^[ \\t]',227 end: '$',228 relevance: 0229 },230 HORIZONTAL_RULE,231 // images and links232 {233 begin: '(link:)?(http|https|ftp|file|irc|image:?):\\S+?\\[[^[]*?\\]',234 returnBegin: true,235 contains: [236 {237 begin: '(link|image:?):',238 relevance: 0239 },240 {241 className: 'link',242 begin: '\\w',243 end: '[^\\[]+',244 relevance: 0245 },246 {247 className: 'string',248 begin: '\\[',249 end: '\\]',250 excludeBegin: true,251 excludeEnd: true,252 relevance: 0253 }254 ],255 relevance: 10256 }257 ]258 };259}260 261export { asciidoc as default };262 