diff options
author | Norbert Preining <norbert@preining.info> | 2023-06-08 03:01:59 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2023-06-08 03:01:59 +0000 |
commit | 538e6d6e7c75b7cca5470604811205f9dbd55c03 (patch) | |
tree | 4807afb694acc9e4ecff2d466d5e37788127d6fb /support/texlab/crates/syntax | |
parent | 5c99135c06494b236cce7fd76e346851cf8c4408 (diff) |
CTAN sync 202306080301
Diffstat (limited to 'support/texlab/crates/syntax')
-rw-r--r-- | support/texlab/crates/syntax/src/latex/cst.rs | 36 | ||||
-rw-r--r-- | support/texlab/crates/syntax/src/latex/kind.rs | 3 |
2 files changed, 35 insertions, 4 deletions
diff --git a/support/texlab/crates/syntax/src/latex/cst.rs b/support/texlab/crates/syntax/src/latex/cst.rs index be64557886..a2945c3e7a 100644 --- a/support/texlab/crates/syntax/src/latex/cst.rs +++ b/support/texlab/crates/syntax/src/latex/cst.rs @@ -265,6 +265,15 @@ impl ToString for Key { cst_node!(Value, VALUE); +impl Value { + pub fn text(&self) -> Option<String> { + match CurlyGroup::cast(self.syntax().clone()) { + Some(group) => group.content_text(), + None => Some(self.syntax().text().to_string()), + } + } +} + cst_node!(KeyValuePair, KEY_VALUE_PAIR); impl KeyValuePair { @@ -528,7 +537,11 @@ impl LabelNumber { } } -cst_node!(TheoremDefinition, THEOREM_DEFINITION); +cst_node!( + TheoremDefinition, + THEOREM_DEFINITION_AMSTHM, + THEOREM_DEFINITION_THMTOOLS +); impl TheoremDefinition { pub fn command(&self) -> Option<SyntaxToken> { @@ -539,8 +552,25 @@ impl TheoremDefinition { self.syntax().children().find_map(CurlyGroupWord::cast) } - pub fn heading(&self) -> Option<CurlyGroup> { - self.syntax().children().find_map(CurlyGroup::cast) + pub fn heading(&self) -> Option<String> { + if self.0.kind() == THEOREM_DEFINITION_THMTOOLS { + let options = self + .syntax() + .children() + .find_map(BrackGroupKeyValue::cast) + .and_then(|group| group.body())?; + + options + .pairs() + .find(|pair| pair.key().map_or(false, |key| key.to_string() == "name")) + .and_then(|pair| pair.value()) + .and_then(|name| name.text()) + } else { + self.syntax() + .children() + .find_map(CurlyGroup::cast) + .and_then(|group| group.content_text()) + } } } diff --git a/support/texlab/crates/syntax/src/latex/kind.rs b/support/texlab/crates/syntax/src/latex/kind.rs index 3eadc90b48..39e2837932 100644 --- a/support/texlab/crates/syntax/src/latex/kind.rs +++ b/support/texlab/crates/syntax/src/latex/kind.rs @@ -73,7 +73,8 @@ pub enum SyntaxKind { ACRONYM_DEFINITION, ACRONYM_DECLARATION, ACRONYM_REFERENCE, - THEOREM_DEFINITION, + THEOREM_DEFINITION_AMSTHM, + THEOREM_DEFINITION_THMTOOLS, COLOR_REFERENCE, COLOR_DEFINITION, COLOR_SET_DEFINITION, |