]>
luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/markdown.js
1 /*! `markdown` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar
= (function () {
8 Author: John Crepezzi <john.crepezzi@gmail.com>
9 Website: https://daringfireball.net/projects/markdown/
10 Category: common, markup
13 function markdown(hljs
) {
14 const regex
= hljs
.regex
;
16 begin: /<\/?[A-Za-z_]/,
21 const HORIZONTAL_RULE
= {
28 // TODO: fix to allow these to work with sublanguage also
29 { begin: '(`{3,})[^`](.|\\n)*?\\1`*[ ]*' },
30 { begin: '(~{3,})[^~](.|\\n)*?\\1~*[ ]*' },
31 // needed to allow markdown as a sublanguage to work
42 begin: '(?=^( {4}|\\t))',
43 // use contains to gobble up multiple lines to allow the block to be whatever size
44 // but only have a single open/close tag vs one per line
57 begin: '^[ \t]*([*+-]|(\\d+\\.))(?=\\s+)',
61 const LINK_REFERENCE
= {
62 begin: /^\[[^\n]+\]:/,
80 const URL_SCHEME
= /[A-Za-z][A-Za-z0-9+.-]*/;
83 // too much like nested array access in so many languages
84 // to have any real relevance
86 begin: /\[.+?\]\[.*?\]/,
89 // popular internet URLs
91 begin: /\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,
95 begin: regex
.concat(/\[.+?\]\(/, URL_SCHEME
, /:\/\/.*?\)/),
100 begin: /\[.+?\]\([./?&#].*?\)/,
103 // whatever else, lower relevance (might not be a link at all)
105 begin: /\[.*?\]\(.*?\)/,
112 // empty strings for alt or link text
142 contains: [], // defined later
149 begin: /\*{2}(?!\s)/,
155 className: 'emphasis',
156 contains: [], // defined later
159 begin: /\*(?![*\s])/,
170 // 3 level deep nesting is not allowed because it would create confusion
171 // in cases like `***testing***` because where we don't know if the last
172 // `***` is starting a new bold/italic or finishing the last one
173 const BOLD_WITHOUT_ITALIC
= hljs
.inherit(BOLD
, { contains: [] });
174 const ITALIC_WITHOUT_BOLD
= hljs
.inherit(ITALIC
, { contains: [] });
175 BOLD
.contains
.push(ITALIC_WITHOUT_BOLD
);
176 ITALIC
.contains
.push(BOLD_WITHOUT_ITALIC
);
189 m
.contains
= m
.contains
.concat(CONTAINABLE
);
192 CONTAINABLE
= CONTAINABLE
.concat(BOLD
, ITALIC
);
195 className: 'section',
200 contains: CONTAINABLE
203 begin: '(?=^.+?\\n[=-]{2,}$)',
205 { begin: '^[=-]*$' },
209 contains: CONTAINABLE
219 contains: CONTAINABLE
,
224 //https://spec.commonmark.org/0.31.2/#entity-references
226 match: /&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/
256 export default hljsGrammar
;