Add symbol support for thmtools package (#897)

This commit is contained in:
Patrick Förster 2023-06-07 09:35:57 +02:00 committed by GitHub
parent 365c04050c
commit f24f35f2a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 200 additions and 21 deletions

View file

@ -138,7 +138,8 @@ impl<'a> Parser<'a> {
CommandName::AcronymDefinition => self.acronym_definition(),
CommandName::AcronymDeclaration => self.acronym_declaration(),
CommandName::AcronymReference => self.acronym_reference(),
CommandName::TheoremDefinition => self.theorem_definition(),
CommandName::TheoremDefinitionAmsThm => self.theorem_definition_amsthm(),
CommandName::TheoremDefinitionThmTools => self.theorem_definition_thmtools(),
CommandName::ColorReference => self.color_reference(),
CommandName::ColorDefinition => self.color_definition(),
CommandName::ColorSetDefinition => self.color_set_definition(),
@ -978,8 +979,8 @@ impl<'a> Parser<'a> {
self.builder.finish_node();
}
fn theorem_definition(&mut self) {
self.builder.start_node(THEOREM_DEFINITION.into());
fn theorem_definition_amsthm(&mut self) {
self.builder.start_node(THEOREM_DEFINITION_AMSTHM.into());
self.eat();
self.trivia();
@ -1002,6 +1003,22 @@ impl<'a> Parser<'a> {
self.builder.finish_node();
}
fn theorem_definition_thmtools(&mut self) {
self.builder.start_node(THEOREM_DEFINITION_THMTOOLS.into());
self.eat();
self.trivia();
if self.lexer.peek() == Some(Token::LBrack) {
self.brack_group_key_value();
}
if self.lexer.peek() == Some(Token::LCurly) {
self.curly_group_word();
}
self.builder.finish_node();
}
fn color_reference(&mut self) {
self.builder.start_node(COLOR_REFERENCE.into());
self.eat();

View file

@ -67,9 +67,8 @@ pub fn classify(name: &str, config: &SyntaxConfig) -> CommandName {
| "Glsentrylong" | "glsentrylongpl" | "Glsentrylongpl" | "glsentryshort"
| "Glsentryshort" | "glsentryshortpl" | "Glsentryshortpl" | "glsentryfullpl"
| "Glsentryfullpl" => CommandName::AcronymReference,
"newtheorem" | "newtheorem*" | "declaretheorem" | "declaretheorem*" => {
CommandName::TheoremDefinition
}
"newtheorem" | "newtheorem*" => CommandName::TheoremDefinitionAmsThm,
"declaretheorem" | "declaretheorem*" => CommandName::TheoremDefinitionThmTools,
"color" | "colorbox" | "textcolor" | "pagecolor" => CommandName::ColorReference,
"definecolor" => CommandName::ColorDefinition,
"definecolorset" => CommandName::ColorSetDefinition,

View file

@ -111,7 +111,8 @@ pub enum CommandName {
AcronymDefinition,
AcronymDeclaration,
AcronymReference,
TheoremDefinition,
TheoremDefinitionAmsThm,
TheoremDefinitionThmTools,
ColorReference,
ColorDefinition,
ColorSetDefinition,

View file

@ -5,7 +5,7 @@ input_file: crates/parser/src/test_data/latex/theorem_definition/theorem_definit
---
ROOT@0..31
PREAMBLE@0..31
THEOREM_DEFINITION@0..31
THEOREM_DEFINITION_AMSTHM@0..31
COMMAND_NAME@0..11 "\\newtheorem"
CURLY_GROUP_WORD@11..16
L_CURLY@11..12 "{"

View file

@ -5,7 +5,7 @@ input_file: crates/parser/src/test_data/latex/theorem_definition/theorem_definit
---
ROOT@0..21
PREAMBLE@0..21
THEOREM_DEFINITION@0..21
THEOREM_DEFINITION_AMSTHM@0..21
COMMAND_NAME@0..11 "\\newtheorem"
CURLY_GROUP_WORD@11..16
L_CURLY@11..12 "{"

View file

@ -5,7 +5,7 @@ input_file: crates/parser/src/test_data/latex/theorem_definition/theorem_definit
---
ROOT@0..21
PREAMBLE@0..21
THEOREM_DEFINITION@0..21
THEOREM_DEFINITION_AMSTHM@0..21
COMMAND_NAME@0..11 "\\newtheorem"
CURLY_GROUP_WORD@11..16
L_CURLY@11..12 "{"

View file

@ -5,7 +5,7 @@ input_file: crates/parser/src/test_data/latex/theorem_definition/theorem_definit
---
ROOT@0..26
PREAMBLE@0..26
THEOREM_DEFINITION@0..26
THEOREM_DEFINITION_AMSTHM@0..26
COMMAND_NAME@0..11 "\\newtheorem"
CURLY_GROUP_WORD@11..16
L_CURLY@11..12 "{"

View file

@ -5,7 +5,7 @@ input_file: crates/parser/src/test_data/latex/theorem_definition/theorem_definit
---
ROOT@0..16
PREAMBLE@0..16
THEOREM_DEFINITION@0..16
THEOREM_DEFINITION_AMSTHM@0..16
COMMAND_NAME@0..11 "\\newtheorem"
CURLY_GROUP_WORD@11..16
L_CURLY@11..12 "{"

View file

@ -0,0 +1,35 @@
---
source: crates/parser/src/latex.rs
expression: root
input_file: crates/parser/src/test_data/latex/theorem_definition/theorem_definition_thmtools.txt
---
ROOT@0..41
PREAMBLE@0..41
THEOREM_DEFINITION_THMTOOLS@0..41
COMMAND_NAME@0..15 "\\declaretheorem"
BRACK_GROUP_KEY_VALUE@15..36
L_BRACK@15..16 "["
KEY_VALUE_BODY@16..35
KEY_VALUE_PAIR@16..25
KEY@16..21
WORD@16..21 "style"
EQUALITY_SIGN@21..22 "="
VALUE@22..25
TEXT@22..25
WORD@22..25 "foo"
COMMA@25..26 ","
WHITESPACE@26..27 " "
KEY_VALUE_PAIR@27..35
KEY@27..31
WORD@27..31 "name"
EQUALITY_SIGN@31..32 "="
VALUE@32..35
TEXT@32..35
WORD@32..35 "bar"
R_BRACK@35..36 "]"
CURLY_GROUP_WORD@36..41
L_CURLY@36..37 "{"
KEY@37..40
WORD@37..40 "baz"
R_CURLY@40..41 "}"

View file

@ -0,0 +1 @@
\declaretheorem[style=foo, name=bar]{baz}