From 92abc00192d1d0bddbccce08a9993d057ddc3dec Mon Sep 17 00:00:00 2001 From: bsmith-n4 Date: Wed, 21 Feb 2018 18:20:00 +0100 Subject: [PATCH 1/2] improve syntax highlighting --- Snippets/Table.sublime-snippet | 6 +- Syntaxes/Asciidoctor.YAML-tmLanguage | 78 +++++++++++-- Syntaxes/Asciidoctor.tmLanguage | 169 +++++++++++++++++++++++++-- 3 files changed, 233 insertions(+), 20 deletions(-) diff --git a/Snippets/Table.sublime-snippet b/Snippets/Table.sublime-snippet index ceb7c23..a2cbebc 100644 --- a/Snippets/Table.sublime-snippet +++ b/Snippets/Table.sublime-snippet @@ -3,12 +3,12 @@ +$0]]> |= text.asciidoc diff --git a/Syntaxes/Asciidoctor.YAML-tmLanguage b/Syntaxes/Asciidoctor.YAML-tmLanguage index 331ea95..fa0f8de 100644 --- a/Syntaxes/Asciidoctor.YAML-tmLanguage +++ b/Syntaxes/Asciidoctor.YAML-tmLanguage @@ -1,7 +1,7 @@ # [PackageDev] target_format: plist, ext: tmLanguage # -*- mode: YAML -*- -name: AsciiDoc (Asciidoctor) +name: Aspec scopeName: text.asciidoc fileTypes: [adoc, ad, asciidoc] uuid: A2AE6D21-3F08-4978-ADF3-55B5AD580921 @@ -25,6 +25,7 @@ repository: - include: '#block_literal' - include: '#block_comment' - include: '#custom_block' + - include: '#table_block' - include: '#block_listing' - include: '#block_source_fenced' - include: '#block_sidebar' @@ -32,6 +33,8 @@ repository: - include: '#block_quote' - include: '#block_example' - include: '#block_open' + - include: '#colconfig' + - include: '#role' block_comment: comment: | @@ -65,6 +68,56 @@ repository: '3': {name: variable.parameter.sourcelang.asciidoc} '4': {name: markup.underline.block.asciidoc} + colconfig: + name: markup.underline.block.id.def.asciidoc + match: | + (?x)^ + (\[) + (cols="(.+)"(.+)?) + (\s*\]) + \s*$\n? + captures: + '1': {name: markup.underline.block.asciidoc} + '2': {name: markup.underline.block.asciidoc} + '3': {name: variable.parameter.sourcelang.asciidoc} + '4': {name: markup.underline.block.asciidoc} + + role: + name: markup.underline.block.id.def.asciidoc + match: | + (?x)^ + (\[) + (\..+) + (\s*\]) + \s*$\n? + captures: + '1': {name: markup.underline.block.asciidoc} + '2': {name: markup.underline.block.asciidoc} + '4': {name: markup.underline.block.asciidoc} + + table_block: + comment: | + A Cool Table + Examples: + |=== + | thing | two + |=== + + name: table.block.asciidoc + begin: (^\|={3,})\s*$\n? + beginCaptures: + '0': {name: variable.parameter.table.delimiter.asciidoc} + end: ^\1\s*$\n? + endCaptures: + '0': {name: variable.parameter.table.delimiter.asciidoc} + patterns: + - include: '#colconfig' + - include: '#block_listing' + - include: '#lines' + - include: '#inline' + - include: '#characters' + - include: '#table_pipe' + block_example: comment: | Examples: @@ -265,6 +318,7 @@ repository: - include: '#indexterm_triple' - include: '#indexterm_double' + attribute_reference: comment: | Examples: @@ -444,6 +498,13 @@ repository: - include: '#superscript' - include: '#subscript' + table_pipe: + comment: default table separator + name: markup.table.pipe.asciidoc + match: ((\d\*)?\.?(>|^|<)?(\w+|\d+)?\|) + captures: + '1': {name: variable.parameter.table.delimiter.asciidoc} + strong_double: comment: | Strong (bold) text (unconstrained variant). @@ -896,7 +957,6 @@ repository: '6': {name: variable.parameter.reqversion.id.asciidoc} '7': {name: markup.underline.block.id.asciidoc} - inline_break: comment: | Line hard break with a plus sign (+). @@ -939,7 +999,7 @@ repository: (\[) # 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 + sect\d|abstract|discrete|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? @@ -1080,42 +1140,42 @@ repository: title_level_0: name: markup.heading.level.0.asciidoc - match: ^(=) (`?\w.*)$\n? + match: ^(=) (.+) captures: '1': {name: punctuation.definition.heading.asciidoc} '2': {name: entity.name.section.asciidoc} title_level_1: name: markup.heading.level.1.asciidoc - match: ^(==) (`?\w.*)$\n? + match: ^(==) (.+) captures: '1': {name: punctuation.definition.heading.asciidoc} '2': {name: entity.name.section.asciidoc} title_level_2: name: markup.heading.level.2.asciidoc - match: ^(===) (`?\w.*)$\n? + match: ^(===) (.+) captures: '1': {name: punctuation.definition.heading.asciidoc} '2': {name: entity.name.section.asciidoc} title_level_3: name: markup.heading.level.3.asciidoc - match: ^(====) (`?\w.*)$\n? + match: ^(====) (.+) captures: '1': {name: punctuation.definition.heading.asciidoc} '2': {name: entity.name.section.asciidoc} title_level_4: name: markup.heading.level.4.asciidoc - match: ^(=====) (`?\w.*)$\n? + match: ^(=====) (.+) captures: '1': {name: punctuation.definition.heading.asciidoc} '2': {name: entity.name.section.asciidoc} title_level_5: name: markup.heading.level.5.asciidoc - match: ^(======) (`?\w.*)$\n? + match: ^(======) (.+) captures: '1': {name: punctuation.definition.heading.asciidoc} '2': {name: entity.name.section.asciidoc} \ No newline at end of file diff --git a/Syntaxes/Asciidoctor.tmLanguage b/Syntaxes/Asciidoctor.tmLanguage index 33f8e4b..698a300 100644 --- a/Syntaxes/Asciidoctor.tmLanguage +++ b/Syntaxes/Asciidoctor.tmLanguage @@ -12,7 +12,7 @@ asciidoc name - AsciiDoc (Asciidoctor) + Aspec patterns @@ -760,6 +760,10 @@ Examples: include #custom_block + + include + #table_block + include #block_listing @@ -788,6 +792,14 @@ Examples: include #block_open + + include + #colconfig + + + include + #role + characters @@ -840,6 +852,41 @@ Examples: + colconfig + + captures + + 1 + + name + markup.underline.block.asciidoc + + 2 + + name + markup.underline.block.asciidoc + + 3 + + name + variable.parameter.sourcelang.asciidoc + + 4 + + name + markup.underline.block.asciidoc + + + match + (?x)^ +(\[) +(cols="(.+)"(.+)?) +(\s*\]) +\s*$\n? + + name + markup.underline.block.id.def.asciidoc + colist_item_marker captures @@ -1953,6 +2000,36 @@ Note: Must be dead first among the inlines, so as to take priority. name constant.character.replacement.asciidoc + role + + captures + + 1 + + name + markup.underline.block.asciidoc + + 2 + + name + markup.underline.block.asciidoc + + 4 + + name + markup.underline.block.asciidoc + + + match + (?x)^ +(\[) +(\..+) +(\s*\]) +\s*$\n? + + name + markup.underline.block.id.def.asciidoc + section_template captures @@ -1985,7 +2062,7 @@ Note: Must be dead first among the inlines, so as to take priority. (\[) # 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 +sect\d|abstract|discrete|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? @@ -2366,6 +2443,82 @@ Examples: + table_block + + begin + (^\|={3,})\s*$\n? + beginCaptures + + 0 + + name + variable.parameter.table.delimiter.asciidoc + + + comment + A Cool Table +Examples: + |=== + | thing | two + |=== + + end + ^\1\s*$\n? + endCaptures + + 0 + + name + variable.parameter.table.delimiter.asciidoc + + + name + table.block.asciidoc + patterns + + + include + #colconfig + + + include + #block_listing + + + include + #lines + + + include + #inline + + + include + #characters + + + include + #table_pipe + + + + table_pipe + + captures + + 1 + + name + variable.parameter.table.delimiter.asciidoc + + + comment + default table separator + match + ((\d\*)?\.?(>|^|<)?(\w+|\d+)?\|) + name + markup.table.pipe.asciidoc + title_level_0 captures @@ -2382,7 +2535,7 @@ Examples: match - ^(=) (`?\w.*)$\n? + ^(=) (.+) name markup.heading.level.0.asciidoc @@ -2402,7 +2555,7 @@ Examples: match - ^(==) (`?\w.*)$\n? + ^(==) (.+) name markup.heading.level.1.asciidoc @@ -2422,7 +2575,7 @@ Examples: match - ^(===) (`?\w.*)$\n? + ^(===) (.+) name markup.heading.level.2.asciidoc @@ -2442,7 +2595,7 @@ Examples: match - ^(====) (`?\w.*)$\n? + ^(====) (.+) name markup.heading.level.3.asciidoc @@ -2462,7 +2615,7 @@ Examples: match - ^(=====) (`?\w.*)$\n? + ^(=====) (.+) name markup.heading.level.4.asciidoc @@ -2482,7 +2635,7 @@ Examples: match - ^(======) (`?\w.*)$\n? + ^(======) (.+) name markup.heading.level.5.asciidoc From f8d3a7d2c0cf9e7180049ec648aed08a2ede42c7 Mon Sep 17 00:00:00 2001 From: bsmith-n4 Date: Wed, 21 Feb 2018 18:33:28 +0100 Subject: [PATCH 2/2] add inline math highlighting --- Syntaxes/Asciidoctor.YAML-tmLanguage | 16 +++++++++++ Syntaxes/Asciidoctor.tmLanguage | 40 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/Syntaxes/Asciidoctor.YAML-tmLanguage b/Syntaxes/Asciidoctor.YAML-tmLanguage index fa0f8de..d85869e 100644 --- a/Syntaxes/Asciidoctor.YAML-tmLanguage +++ b/Syntaxes/Asciidoctor.YAML-tmLanguage @@ -35,6 +35,7 @@ repository: - include: '#block_open' - include: '#colconfig' - include: '#role' + - include: '#inline_math' block_comment: comment: | @@ -117,6 +118,7 @@ repository: - include: '#inline' - include: '#characters' - include: '#table_pipe' + - include: '#inline_math' block_example: comment: | @@ -299,6 +301,20 @@ repository: '1': {name: punctuation.definition.callout.begin.asciidoc} '2': {name: punctuation.definition.callout.end.asciidoc} + inline_math: + comment: | + Callout label + + Examples: + <1> + <42> + name: constant.other.callout.asciidoc + match: (\$)(.+?)(\$) + captures: + '1': {name: punctuation.definition.math.begin.asciidoc} + '2': {name: markup.underline.block.asciidoc} + '3': {name: punctuation.definition.math.end.asciidoc} + #-----------------------------------------------------------------------------# # C H A R A C T E R S # diff --git a/Syntaxes/Asciidoctor.tmLanguage b/Syntaxes/Asciidoctor.tmLanguage index 698a300..da8470f 100644 --- a/Syntaxes/Asciidoctor.tmLanguage +++ b/Syntaxes/Asciidoctor.tmLanguage @@ -800,6 +800,10 @@ Examples: include #role + + include + #inline_math + characters @@ -1380,6 +1384,38 @@ Examples: name comment.line.double-slash.asciidoc + inline_math + + captures + + 1 + + name + punctuation.definition.math.begin.asciidoc + + 2 + + name + markup.underline.block.asciidoc + + 3 + + name + punctuation.definition.math.end.asciidoc + + + comment + Callout label + +Examples: + <1> + <42> + + match + (\$)(.+?)(\$) + name + constant.other.callout.asciidoc + lines patterns @@ -2500,6 +2536,10 @@ Examples: include #table_pipe + + include + #inline_math + table_pipe