Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- { scopeName = 'text.html.markdown';
- fileTypes = ( 'markdown', 'mdown', 'markdn', 'md' );
- foldingStartMarker = '(?x)
- (<(?i:head|body|table|thead|tbody|tfoot|tr|div|select|fieldset|style|script|ul|ol|form|dl)\b.*?>
- |<!--(?!.*-->)
- |\{\s*($|\?>\s*$|//|/\*(.*\*/\s*$|(?!.*?\*/)))
- )';
- foldingStopMarker = '(?x)
- (</(?i:head|body|table|thead|tbody|tfoot|tr|div|select|fieldset|style|script|ul|ol|form|dl)>
- |^\s*-->
- |(^|\s)\}
- )';
- patterns = (
- { name = 'meta.separator.markdown';
- match = '^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$\n?';
- },
- { name = 'meta.separator.markdown';
- match = '^[ ]{0,2}([ ]?-[ ]?){3,}[ \t]*$\n?';
- },
- { name = 'meta.separator.markdown';
- match = '^[ ]{0,2}([ ]?_[ ]?){3,}[ \t]*$\n?';
- },
- { name = 'markup.heading.markdown';
- match = '^#{1,6}\s*(.*?)\s*#*$';
- captures = { 1 = { name = 'entity.name.function'; }; };
- },
- { name = 'markup.list.unnumbered';
- begin = '^\s{0,3}[*+-](?=\s)';
- end = '^(?=\S)';
- patterns = ( { include = '#list-paragraph'; } );
- },
- { name = 'markup.list.numbered';
- begin = '^\s{0,3}[0-9]+\.(?=\s)';
- end = '^(?=\S)';
- patterns = ( { include = '#list-paragraph'; } );
- },
- { name = 'markup.quote.markdown';
- begin = '^\s*>';
- end = '^\s*$';
- patterns = ( { include = '#inline'; } );
- },
- { name = 'markup.raw.block.markdown';
- begin = ' {4,}|\t';
- end = '^\s*$';
- },
- { name = 'meta.disable-markdown';
- comment = "Markdown formatting is disabled inside block-level tags. We only do that when a tag is at the start of a line (which only contains that tag). It would be better to list exactly which tags this should happen for (but I'm lazy) -- Allan";
- begin = '^(?=<(\w+)[^>]*(?<!/)>$)';
- end = '(?<=^</\1>$\n)';
- patterns = ( { include = 'text.html.basic'; } );
- },
- { name = 'meta.link.reference.def.markdown';
- match = '(?x:
- \s* # Leading whitespace
- \[(.+?)\]: # Reference name
- [ \t]* # Optional whitespace
- <?(\S+?)>? # The url
- [ \t]* # Optional whitespace
- (?:
- (\(.+?\)) # Match title in quotes…
- | (".+?") # or in parens.
- | (''.+?'')
- )? # Title is optional
- \s* # Optional whitespace
- $
- )';
- captures =
- { 1 = { name = 'constant.other.reference.link.markdown'; };
- 2 = { name = 'markup.underline.link.markdown'; };
- 3 = { name = 'string.other.link.description.title.markdown'; };
- 4 = { name = 'string.other.link.description.title.markdown'; };
- 5 = { name = 'string.other.link.description.title.markdown'; };
- };
- },
- { name = 'meta.paragraph.markdown';
- begin = '^(?=\S)(?!^[=-]{3,}(?=$))';
- end = '(^(?:\s*$|(?=\s*>))|(?<=^===|^====|=====)[ \t]*\n|(?<=^---|^----|-----)[ \t]*\n)';
- patterns = (
- { include = '#inline'; },
- { include = 'text.html.basic'; },
- { name = 'markup.heading.1.markdown';
- match = '^={3,}(?=[ \t]*$)';
- },
- { name = 'markup.heading.2.markdown';
- match = '^-{3,}(?=[ \t]*$)';
- },
- );
- },
- );
- repository = {
- inline = {
- patterns = (
- { include = '#escape'; },
- { include = '#ampersand'; },
- { include = '#raw'; },
- { include = '#bold'; },
- { include = '#italic'; },
- { include = '#line-break'; },
- { include = '#image-inline'; },
- { include = '#link-inline'; },
- { include = '#link-inet'; },
- { include = '#link-email'; },
- { include = '#image-ref'; },
- { include = '#link-ref-literal'; },
- { include = '#link-ref'; },
- );
- };
- escape = {
- name = 'constant.character.escape.markdown';
- match = '\\[-`*_#+.!(){}\[\]\\]';
- };
- ampersand = {
- name = 'meta.other.valid-ampersand.markdown';
- comment = "Markdown will convert this for us. We match it so that the HTML grammar won't mark it up as invalid.";
- match = '&(?!([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+);)';
- };
- raw = {
- patterns = (
- { name = 'markup.raw.inline.markdown';
- match = '``.*?``';
- },
- { name = 'markup.raw.inline.markdown';
- match = '`([^\\`]|\\.)*?`';
- },
- );
- };
- bold = {
- name = 'markup.bold.markdown';
- begin = '(?x)
- (\*\*|__)(?=\S) # Open
- (?=
- (
- [^\<`\[\\] # Ignore html tags and
- # raw states.
- | <[^>]*+> # HTML tags
- | <(?=[^>\n]*+$) # Open bracket otherwise
- | ``([^`]|`(?!`))*+`` # Raw v1
- | `([^\\`]|\\.)*+` # Raw v2
- | \\[\\`*_{}\[\]()#.!] # Escapes
- | \\(?=[^\\`*_{}\[\]()#.!]) # Slash no an escape
- | \[
- (?<link>
- (?<square> # Named group
- [^\[\]\\] # Match most chars
- | \\. # Escaped chars
- | \[ \g<square>*+ \] # Nested brackets
- )*+
- \]
- (
- ( # Reference Link
- [ ]? # Optional space
- \[[^\]]*+\] # Ref name
- )
- | ( # Inline Link
- \( # Opening paren
- [ \t]*+ # Optional whtiespace
- <?(.*?)>? # URL
- [ \t]*+ # Optional whtiespace
- ( # Optional Title
- (?<title>[''"])
- (.*?)
- \k<title>
- )?
- \)
- )
- )
- )
- | \[(?!\g<link>)
- )*?
- (?<!
- [^\\]\\ # Crazy check for
- | [^\\]\\\\\\ # escapes before the
- | [^\\]\\\\\\\\\\ # end condition.
- )
- (?<=\S)\1 # Close
- )
- ';
- end = '(?<=\S)\1';
- patterns = (
- { begin = '(?=<[^>]*?>)';
- end = '(?<=>)';
- patterns = (
- { include = 'text.html.basic'; },
- );
- },
- { name = 'markup.italic.markdown';
- comment = 'Match simple italics for speed';
- match = '(\*|_)(?=\S)[-a-zA-Z0-9. ]+?(?<=\S)\1';
- },
- { include = '#escape'; },
- { include = '#ampersand'; },
- { include = '#raw'; },
- { include = '#italic'; },
- { include = '#image-inline'; },
- { include = '#link-inline'; },
- { include = '#link-inet'; },
- { include = '#link-email'; },
- { include = '#image-ref'; },
- { include = '#link-ref-literal'; },
- { include = '#link-ref'; },
- );
- };
- italic = {
- name = 'markup.italic.markdown';
- begin = '(\*|_)(?=\S)(?=(.+?[*_]*)(?<![^\\]\\|[^\\]\\\\\\|[^\\]\\\\\\\\\\)(?<=\S)\1)';
- end = '(?<=\S)\1';
- patterns = (
- { begin = '(?=<[^>]*?>)';
- end = '(?<=>)';
- patterns = (
- { include = 'text.html.basic'; },
- );
- },
- { name = 'markup.bold.markdown';
- comment = 'Match simple bolds for speed';
- match = '(\*\*|__)(?=\S)[-a-zA-Z0-9. ]+?(?<=\S)\1';
- },
- { include = '#escape'; },
- { include = '#ampersand'; },
- { include = '#raw'; },
- { include = '#bold'; },
- { include = '#image-inline'; },
- { include = '#link-inline'; },
- { include = '#link-inet'; },
- { include = '#link-email'; },
- { include = '#image-ref'; },
- { include = '#link-ref-literal'; },
- { include = '#link-ref'; },
- );
- };
- line-break = {
- name = 'meta.dummy.line-break';
- match = ' {2,}$';
- };
- image-inline = {
- name = 'meta.image.inline.markdown';
- match = '(?x:
- \! # Images start with !
- \[([^\]]*?)\] # Match the link text.
- ([ ]?) # Space not allowed
- \( # Opening paren for url
- <?(\S+?)>? # The url
- [ \t]* # Optional whitespace
- (?:
- (\(.+?\)) # Match title in parens…
- | (".+?") # or in quotes.
- )? # Title is optional
- \s* # Optional whitespace
- \)
- )';
- captures =
- { 1 = { name = 'string.other.link.description.markdown'; };
- 2 = { name = 'invalid.illegal.whitespace.markdown'; };
- 3 = { name = 'markup.underline.link.image.markdown'; };
- 4 = { name = 'string.other.link.description.title.markdown'; };
- 5 = { name = 'string.other.link.description.title.markdown'; };
- };
- };
- link-inline = {
- name = 'meta.link.inline.markdown';
- match = '(?x:
- \[([^\]]*?)\] # Match the link text.
- ([ ]?) # Space not allowed
- \( # Opening paren for url
- <?(\S*?)>? # The url
- [ \t]* # Optional whitespace
- (?:
- (\(.+?\)) # Match title in parens…
- | (".+?") # or in quotes.
- )? # Title is optional
- \s* # Optional whitespace
- \)
- )';
- captures =
- { 1 = { name = 'string.other.link.title.markdown'; };
- 2 = { name = 'invalid.illegal.whitespace.markdown'; };
- 3 = { name = 'markup.underline.link.markdown'; };
- 4 = { name = 'string.other.link.description.title.markdown'; };
- 5 = { name = 'string.other.link.description.title.markdown'; };
- };
- };
- link-inet = {
- name = 'meta.link.inet.markdown';
- match = '<((?:https?|ftp)://.*?)>';
- captures = { 1 = { name = 'markup.underline.link.markdown'; }; };
- };
- link-email = {
- name = 'meta.link.email.lt-gt.markdown';
- match = '<((?:mailto:)?[-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>';
- captures = { 1 = { name = 'markup.underline.link.markdown'; }; };
- };
- image-ref = {
- name = 'meta.image.reference.markdown';
- match = '\!\[(.*?)\] *\[(.*?)\]';
- captures =
- { 1 = { name = 'string.other.link.description.markdown'; };
- 2 = { name = 'constant.other.reference.link.markdown'; };
- };
- };
- link-ref-literal = {
- name = 'meta.link.reference.literal.markdown';
- match = '\[(([^\[\]]|\[.*+\])*+)\] *\[\]';
- captures =
- { 1 = { name = 'string.other.link.title.markdown'; };
- };
- };
- link-ref = {
- name = 'meta.link.reference.markdown';
- match = '\[(([^\[\]]|\[.*+\])*+)\] *\[[^\]]*+\]';
- captures =
- { 1 = { name = 'string.other.link.title.markdown'; };
- 3 = { name = 'constant.other.reference.link.markdown'; };
- };
- };
- list-paragraph = { patterns = (
- { name = 'meta.paragraph.list.markdown';
- begin = '\G\s+(?=\S)';
- end = '^\s*$';
- patterns = ( { include = '#inline'; } );
- }
- );
- };
- };
- }
Add Comment
Please, Sign In to add comment