Skip to content

Commit

Permalink
Allow commands as children of text nodes
Browse files Browse the repository at this point in the history
See #29.
  • Loading branch information
pfoerster committed Feb 26, 2022
1 parent 7a3d14d commit 1ea9f87
Show file tree
Hide file tree
Showing 7 changed files with 432,259 additions and 398,615 deletions.
100 changes: 57 additions & 43 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,48 +54,17 @@ module.exports = grammar({
),

_text_content: $ =>
choice(
$.curly_group,
$.text,
$.displayed_equation,
$.inline_formula,
$.math_set,
$.block_comment,
$._command
),

_command: $ =>
choice(
$.package_include,
$.class_include,
$.latex_include,
$.biblatex_include,
$.bibtex_include,
$.graphics_include,
$.svg_include,
$.inkscape_include,
$.verbatim_include,
$.import_include,
$.caption,
$.citation,
$.label_definition,
$.label_reference,
$.label_reference_range,
$.label_number,
$.new_command_definition,
$.old_command_definition,
$.let_command_definition,
$.environment_definition,
$.glossary_entry_definition,
$.glossary_entry_reference,
$.acronym_definition,
$.acronym_reference,
$.theorem_definition,
$.color_definition,
$.color_set_definition,
$.color_reference,
$.tikz_library_import,
$.generic_command
prec.right(
1,
choice(
$.curly_group,
$.block_comment,
$._command,
$.text,
$.displayed_equation,
$.inline_formula,
$.math_set
)
),

//--- Sections
Expand Down Expand Up @@ -369,7 +338,18 @@ module.exports = grammar({

text: $ =>
prec.right(
repeat1(field('word', choice($.operator, $.word, $.placeholder)))
repeat1(
field(
'word',
choice(
$.operator,
$.word,
$.placeholder,
$.block_comment,
$._command
)
)
)
),

word: $ => /[^\s\\%\{\},\$\[\]\(\)=\#]+/,
Expand Down Expand Up @@ -562,6 +542,40 @@ module.exports = grammar({

//--- Command

_command: $ =>
choice(
$.package_include,
$.class_include,
$.latex_include,
$.biblatex_include,
$.bibtex_include,
$.graphics_include,
$.svg_include,
$.inkscape_include,
$.verbatim_include,
$.import_include,
$.caption,
$.citation,
$.label_definition,
$.label_reference,
$.label_reference_range,
$.label_number,
$.new_command_definition,
$.old_command_definition,
$.let_command_definition,
$.environment_definition,
$.glossary_entry_definition,
$.glossary_entry_reference,
$.acronym_definition,
$.acronym_reference,
$.theorem_definition,
$.color_definition,
$.color_set_definition,
$.color_reference,
$.tikz_library_import,
$.generic_command
),

generic_command: $ =>
prec.right(
seq(
Expand Down

0 comments on commit 1ea9f87

Please sign in to comment.