%YAML 1.2 --- # http://www.sublimetext.com/docs/3/syntax.html name: AsciiDoc (Asciidoctor) file_extensions: - adoc - ad - asciidoc scope: text.asciidoc contexts: main: - 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: meta.attributeentry.asciidoc - meta_content_scope: meta.attributeentry.value.asciidoc - match: $\n? pop: true - 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)^ (\[) # 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 ) (".*(\])|(\])) # 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.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)(?>)(?!<)' comment: | Internal cross-reference Examples: <> <> scope: meta.xref.asciidoc captures: 1: constant.character.xref.begin.asciidoc 2: markup.underline.term.xref.asciidoc 5: variable.parameter.xref.asciidoc 6: constant.character.xref.end.asciidoc