diff --git a/.gitmodules b/.gitmodules index 6f8d0a26..6b1cff40 100644 --- a/.gitmodules +++ b/.gitmodules @@ -94,9 +94,6 @@ [submodule "assets/themes/sublime-snazzy"] path = assets/themes/sublime-snazzy url = https://github.com/greggb/sublime-snazzy -[submodule "assets/syntaxes/AsciiDoc"] - path = assets/syntaxes/02_Extra/AsciiDoc - url = https://github.com/SublimeText/AsciiDoc.git [submodule "assets/syntaxes/Assembly (ARM)"] path = assets/syntaxes/02_Extra/Assembly (ARM) url = https://github.com/tvi/Sublime-ARM-Assembly @@ -185,3 +182,6 @@ [submodule "assets/syntaxes/02_Extra/QML"] path = assets/syntaxes/02_Extra/QML url = https://github.com/skozlovf/Sublime-QML +[submodule "assets/syntaxes/02_Extra/AsciiDoc"] + path = assets/syntaxes/02_Extra/AsciiDoc + url = https://github.com/asciidoctor/sublimetext-asciidoc.git diff --git a/assets/syntaxes/02_Extra/AsciiDoc b/assets/syntaxes/02_Extra/AsciiDoc index d0089991..e316a0a8 160000 --- a/assets/syntaxes/02_Extra/AsciiDoc +++ b/assets/syntaxes/02_Extra/AsciiDoc @@ -1 +1 @@ -Subproject commit d0089991e5db83a6cb2c505b2ea3548f559ed2af +Subproject commit e316a0a85c67c3edb73a46fc3a3ec4a9dfbbba40 diff --git a/assets/syntaxes/02_Extra/AsciiDoc.sublime-syntax b/assets/syntaxes/02_Extra/AsciiDoc.sublime-syntax index 7bc64431..78f8b902 100644 --- a/assets/syntaxes/02_Extra/AsciiDoc.sublime-syntax +++ b/assets/syntaxes/02_Extra/AsciiDoc.sublime-syntax @@ -1,283 +1,997 @@ %YAML 1.2 --- # http://www.sublimetext.com/docs/3/syntax.html -name: AsciiDoc -comment: | - A very early hack. Mostly ripped from other syntaxes. - Only the very basic stuff is working. +name: AsciiDoc (Asciidoctor) file_extensions: - adoc + - ad - asciidoc - - asc -scope: text.html.asciidoc +scope: text.asciidoc contexts: main: - - include: heading_inline - - include: heading-block - - include: heading-blockattr - - match: \$\$(?!\$) + - include: lists + - include: blocks + - include: section_titles + - include: lines + - include: inline + - include: characters + attribute_entry: + - match: |- + (?x) + ^(:) # opening delimiter + (!)? # bang symbol (unset attribute) + ([A-Za-z0-9_][A-Za-z0-9_-]*) # attribute name + (!)? # bang symbol (unset attribute) + (:) # closing delimiter + (?:\s+|(?=$)) + comment: | + An attribute entry. + + Examples: + :my-attribute: value + :sectnums!: + :!sectnums: + captures: + 1: punctuation.definition.attributeentry.attrname.begin.asciidoc + 2: punctuation.definition.attributeentry.unset.asciidoc + 3: support.variable.attribute.asciidoc + 4: punctuation.definition.attributeentry.unset.asciidoc + 5: punctuation.definition.attributeentry.attrname.end.asciidoc push: - - meta_scope: comment.block.passthrough.macro.doubledollar.asciidoc - - match: \$\$(?!\$) + - meta_scope: meta.attributeentry.asciidoc + - meta_content_scope: meta.attributeentry.value.asciidoc + - match: $\n? pop: true - - match: \+\+\+(?!\+) + - include: characters + attribute_list_line: + - match: '^(\[)[^\[\]]*(\])\s*$\n?' + comment: "Attribute list as paragraph: single brackets. No need for special treatment of escape; follows literal block, section template as being a more general regex." + scope: support.variable.attributelist.asciidoc + captures: + 1: punctuation.definition.attributelistline.begin.asciidoc + 2: punctuation.definition.attributelistline.end.asciidoc + attribute_reference: + - match: "({)([A-Za-z0-9_][A-Za-z0-9_-]*)(})" + comment: | + Examples: + {my-attribute} + scope: variable.other + captures: + 1: constant.character.attributes.reference.begin.asciidoc + 2: support.variable.attribute.asciidoc + 3: constant.character.attributes.reference.end.asciidoc + biblio_anchor: + - match: '(?)))\s+(?=\S) + comment: | + Marker of a callout list item. + + Examples: + <1> a callout + <42> another callout + scope: markup.list.numbered.callout.asciidoc + captures: + 1: string.unquoted.list.callout.asciidoc + 2: constant.numeric.callout.asciidoc + 3: punctuation.definition.calloutlistnumber.begin.asciidoc + 4: punctuation.definition.calloutlistnumber.end.asciidoc + dlist_item_label: + - match: '^\s*(?=.*:{2,4}(?:\s|$))' + comment: | + Label of a definition (labeled) list item. + + Examples: + Label level 1:: lorem ipsum + Label level 2::: dolor sit amet + Label level 3:::: consectetur + Label level 1:: + lorem ipsum + Another label :: lorem ipsum + Last::label:: dolor sit amet + + Note: This rule is not strictly correct, because Asciidoctor allows + double colon followed by a space inside a label, i.e. it matches the + *last* double colon, not the first. I don't know how to do that + *effectively. + push: + - meta_scope: markup.list.labeled.asciidoc + - meta_content_scope: meta.list.label.asciidoc + - match: '(:{2,4})(?:\s|$\n?)' + captures: + 1: constant.labeledlist.separator.asciidoc + pop: true + - include: inline + - include: characters + emphasis: + - match: |- + (?x) + (\[[^\]]*?\])? # might be preceded by an attributes list + (?<=^|\W)(?:])' + comment: | + List of special characters that may be escaped. + + Note: I do not really know if this is a good list, adopted wholesale from + original bundle. + scope: constant.character.escape.asciidoc + indexterm_double: + - match: '(?) + comment: | + Callout label + + Examples: + <1> + <42> + scope: constant.other.callout.asciidoc + captures: + 1: punctuation.definition.callout.begin.asciidoc + 2: punctuation.definition.callout.end.asciidoc + inline_comment: + - match: '^(//)([^/\n].*|)$\n?' + comment: | + Inline comment. + + Examples: + // This is just a comment! scope: comment.line.double-slash.asciidoc + captures: + 1: punctuation.definition.comment.line.asciidoc + 2: meta.line.comment.content.asciidoc + lines: + - include: inline_comment + - include: list_continuation + - include: inline_break + - include: block_page_break + - include: block_thematic_break + - include: block_title + - include: block_id + - include: section_template + - include: attribute_list_line + - include: attribute_entry + list_continuation: + - match: ^\+\s*$\n? + scope: constant.listcontinuation.asciidoc + lists: + - include: block_admonition_label + - include: ulist_item_marker + - include: olist_item_marker + - include: dlist_item_label + - include: colist_item_marker + macro: + - match: |- + (?x) + (?: + ((?:https?|mailto|ftp|file) # specify separately so we can mark them as links that TextMate opens + ?:{1} # inline only + \S*) # (others such as image are partial URLs and/or TextMate cannot handle them) + | + (([a-zA-Z0-9][a-zA-Z0-9_]*) + (:{1,2}) + (\S*)) + ) + (?:(\[)([^\]]*)(\])) + comment: | + Note: There are other macro notations, but I match only those that end in + square brackets. + scope: meta.macro.asciidoc + captures: + 1: markup.underline.link.macro.asciidoc + 3: keyword.control.name.macro.asciidoc + 4: constant.character.separator.macro.asciidoc + 5: markup.underline.target.macro.asciidoc + 6: constant.character.attributes.macro.begin.asciidoc + 7: variable.parameter.attributes.macro.asciidoc + 8: constant.character.attributes.macro.end.asciidoc + macro_pass: + - match: |- + (?x) + (pass) + (:{1,2}) + (\S*) + (\[)(?=[^\]]*\]) + comment: | + Passthrough macro + + Examples: + pass:[Lorem ipsum] + pass::[Lorem ipsum] + captures: + 1: keyword.control.name.macro.pass.asciidoc + 2: constant.character.separator.macro.asciidoc + 3: markup.underline.target.macro.asciidoc + 4: constant.character.attributes.macro.begin.asciidoc + push: + - meta_scope: meta.macro.pass.asciidoc + - meta_content_scope: variable.parameter.attributes.macro.pass.asciidoc + - match: '\]' + captures: + 0: constant.character.attributes.macro.end.asciidoc + pop: true + - include: scope:text.xml + mark: + - match: |- + (?x) + (\[[^\]]*?\])? # might start with attribute list (darned well better or why are we here) + (?<=^|\W)(? + | <\- + | => + | <= + ) + scope: constant.character.replacement.asciidoc + section_template: - match: |- (?x)^ - (?= ([/+-.*_=]{4,})\s*$ - | ([ \t]{1,}) - | [=]{1,6}\s*+ - | [ ]{,3}(?[-*_])([ ]{,2}\k){2,}[ \t]*+$ + (\[) # in square brackets + (template\s*=\s*)?(")? # might start with template-equals and might have template name in quotes + ( + sect\d|abstract|preface|colophon|dedication|glossary|bibliography|synopsis|appendix|index # fixed list of known templates ) - push: - - meta_scope: meta.block-level.asciidoc - - match: |- - (?x)^ - (?! \1 - | ([ \t]{1,}) - | [=]{1,6}\s*+ - | [ ]{,3}(?[-*_])([ ]{,2}\k){2,}[ \t]*+$ - ) - pop: true - - include: block_quote - - include: block_raw - - include: heading_inline - - include: heading-block - - include: separator - - match: '^[ ]{0,3}([*+-])(?=\s)' + (".*(\])|(\])) # either close the quote (and perhaps go on) and close the bracket, or close the bracket immediately + \s*$\n? + comment: fixed list of known template names + scope: variable.parameter.sectiontemplate.asciidoc captures: - 1: punctuation.definition.list_item.asciidoc - push: - - meta_scope: markup.list.unnumbered.asciidoc - - match: ^(?=\S) - captures: - 1: punctuation.definition.list_item.asciidoc - pop: true - - include: list-paragraph - - match: '^[ ]{0,3}[0-9]+(\.)(?=\s)' - captures: - 1: punctuation.definition.list_item.asciidoc - push: - - meta_scope: markup.list.numbered.asciidoc - - match: ^(?=\S) - captures: - 1: punctuation.definition.list_item.asciidoc - pop: true - - include: list-paragraph - - match: '^([/+-.*_=]){4,}\s*$' - push: - - meta_scope: comment.block.asciidoc - - match: '^\1{4,}\s*$' - pop: true - - match: '^([/+.]){4,}\s*$' - comment: asciidoc formatting is disabled inside certain blocks. - push: - - meta_scope: meta.disable-asciidoc - - match: '^[/+.]{4,}\s*$' - pop: true - - match: '^(?=\S)(?![=-]{3,}(?=$))(?!\.\S+)' - push: - - meta_scope: meta.paragraph.asciidoc - - match: '^(?:\s*$|(?=[ ]{,3}>.))|(?=[ \t]*\n)(?<=^===|^====|=====|^---|^----|-----)[ \t]*\n' - pop: true - - include: inline - - include: scope:text.html.basic - - match: '^(={3,})(?=[ \t]*$)' - scope: markup.heading.0.asciidoc - captures: - 1: punctuation.definition.heading.asciidoc - - match: '^(-{3,})(?=[ \t]*$)' - scope: markup.heading.1.asciidoc - captures: - 1: punctuation.definition.heading.asciidoc - - match: '^(~{3,})(?=[ \t]*$)' - scope: markup.heading.2.asciidoc - captures: - 1: punctuation.definition.heading.asciidoc - - match: '^(\^{3,})(?=[ \t]*$)' - scope: markup.heading.3.asciidoc - captures: - 1: punctuation.definition.heading.asciidoc - - match: '^(\+{3,})(?=[ \t]*$)' - scope: markup.heading.4.asciidoc - captures: - 1: punctuation.definition.heading.asciidoc - attribute-entry: - - match: '^:[-_. A-Za-z0-9]+:\s*(.*)\s*$' - scope: variable.other - attribute-reference: - - match: "{[-_. A-Za-z0-9]+}" - scope: variable.other - attribute-reference-predefined: - - match: "{(?i:amp|asciidoc-dir|asciidoc-file|asciidoc-version|author|authored|authorinitials|backend-docbook|backend-xhtml11|backend-html4|docbook-article|xhtml11-article|html4-article|docbook-book|xhtml11-book|html4-book|docbook-manpage|xhtml11-manpage|html4-manpage|backend|backslash|basebackend|brvbar|date|docdate|doctime|docname|docfile|docdir|doctitle|doctype-article|doctype-book|doctype-manpage|doctype|email|empty|encoding|filetype|firstname|gt|id|indir|infile|lastname|level|listindex|localdate|localtime|lt|manname|manpurpose|mantitle|manvolnum|middlename|nbsp|outdir|outfile|reftext|revision|sectnum|showcomments|title|two_colons|two_semicolons|user-dir|verbose)}" - scope: support.variable - block_quote: - - match: '^([/+-.*_=]){4,}\s*$' - push: - - meta_scope: comment.block.asciidoc - - match: '^\1{4,}\s*$' - pop: true - block_raw: - - match: '\G([ ]{4}|\t).*$\n?' - scope: markup.raw.block.asciidoc - bracket: - - match: '<(?![a-z/?\$!])' + 1: punctuation.definition.sectiontemplate.begin.asciidoc + 4: meta.tag.sectiontemplate.asciidoc + 6: punctuation.definition.sectiontemplate.end.asciidoc + 7: punctuation.definition.sectiontemplate.end.asciidoc + section_titles: + - include: title_level_5 + - include: title_level_4 + - include: title_level_3 + - include: title_level_2 + - include: title_level_1 + - include: title_level_0 + strong: + - match: |- + (?x) + (\[[^\]]*?\])? # might start with an attributes list + (?<=^|\W)(?|<-|=>|<= - scope: constant.character.asciidoc - escape: - - match: '\\[-`*_#+.!(){}\[\]\\>:]' - scope: constant.character.escape.asciidoc - heading: - - match: '(?m)^(\S+)$([=-~^+])+\s*$' - scope: markup.heading.asciidoc + Strong (bold) text (constrained variant). + + Examples: + *Lorem ipsum* dolor + [red]*Lorem ipsum* dolor + captures: + 1: support.variable.attributelist.asciidoc + 2: punctuation.definition.bold.single.begin.asciidoc + push: + - meta_scope: markup.bold.single.asciidoc + - meta_content_scope: meta.boldinner.single.asciidoc + - match: |- + (?x) + (?<=\S)(\*) # delimiter star that must be preceded by a nonspace character + (?!\w) # ...and followed by a nonword character + captures: + 1: punctuation.definition.bold.single.end.asciidoc + pop: true + - include: emphasis_double + - include: monospaced_double + - include: mark_double + - include: emphasis + - include: monospaced + - include: mark + - include: superscript + - include: subscript + - include: characters + strong_double: + - match: |- + (?x) + (\[[^\]]*?\])? # might start with an attribute list + (?>)(?!<)' + comment: | + Internal cross-reference + + Examples: + <> + <> + scope: meta.xref.asciidoc captures: - 1: punctuation.definition.italic.asciidoc - push: - - meta_scope: markup.italic.asciidoc - - match: (?<=\S)(\1)((?!\1)|(?=\1\1))(?!\w) - captures: - 1: punctuation.definition.italic.asciidoc - pop: true - text-italic-unconstrained: - - match: (__)(?=\S) - captures: - 1: punctuation.definition.italic.asciidoc - push: - - meta_scope: markup.italic.asciidoc - - match: (?<=\S)(\1) - captures: - 1: punctuation.definition.italic.asciidoc - pop: true - text-monospace: - - match: '(?