Skip to content

Commit

Permalink
Add DeclareMathSymbol to indexed command definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
PHPirates committed Nov 20, 2024
1 parent 717fedd commit e993dd5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Added
* Use xdg-mime to choose a default pdf viewer in the run configuration template
* Don't insert the right brace when in front of text
* Add DeclareMathSymbol to indexed command definitions in installed packages

### Fixed
* Fix exceptions in structure view when command parameters are missing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class LatexExternalCommandDataIndexer : DataIndexer<String, String, FileContent>
*
* Similar: \DeclareTextSymbol, \DeclareTextAccent, \DeclareTextComposite, \DeclareTextCompositeCommand
*/
val declareTextSymbolRegex = """\\DeclareText(?:Symbol|Accent)\{(?<key>[^}]+)}(?<value>\{(?<encoding>[^}]+)}(?:.+)*?\{(?<slot>[^}]+)})""".toRegex()
val declareTextSymbolRegex = """\\Declare(?:Text|Math)(?:Symbol|Accent)\{(?<key>[^}]+)}(?<value>\{(?<encoding>[^}]+)}(?:.+)*?\{(?<slot>[^}]+)})""".toRegex()
val declareTextCommandRegex = """\\DeclareTextCommand\{(?<key>[^}]+)}\{(?<value>[^}]+)}""".toRegex()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,22 @@ class LatexExternalCommandDataIndexerTest : BasePlatformTestCase() {
assertEquals("", map["\\textless"])
}

fun testDeclareMathSymbol() {
val text = """
% It would ok to use \cs{let} for those declared by
% \cs{DeclareMathSymbol} but for a cleaner interface we avoid it
% always (just in case the internals change).
% \begin{macrocode}
\DeclareMathSymbol{\leq}{\mathrel}{symbols}{"14}
\DeclareMathSymbol{\geq}{\mathrel}{symbols}{"15}
% \end{macrocode}
""".trimIndent()
val file = myFixture.configureByText("fontdef.dtx", text)
val map = LatexExternalCommandDataIndexer().map(MockContent(file))
assertEquals(2, map.size)
assertEquals("", map["\\leq"])
}

fun testDef() {
val text = """
\blank@linefalse \def\par{\ifblank@line
Expand Down

0 comments on commit e993dd5

Please sign in to comment.