Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions CellsToTeX/CellsToTeX.m
Original file line number Diff line number Diff line change
Expand Up @@ -1340,9 +1340,16 @@ cell form (String or None)."
rules
,
(type_ -> {_, command_}) :>
With[{start = "\\" <> command <> "{"},
With[
{
start =
$commandCharsToTeX[[1, 1]] <> command <>
$commandCharsToTeX[[2, 1]],
end = $commandCharsToTeX[[3, 1]]
}
,
SyntaxBox[boxes_, type, ___] :>
start <> makeString[boxes] <> "}"
start <> makeString[boxes] <> end
]
,
{1}
Expand Down Expand Up @@ -1682,13 +1689,14 @@ cell form (String or None)."
#1["\[Integral]", scr_, OptionsPattern[]] :>
With[
{
escChar = $commandCharsToTeX[[1, 1]],
argStart = $commandCharsToTeX[[2, 1]],
argEnd = $commandCharsToTeX[[3, 1]]
}
,
StringJoin[
$commandCharsToTeX[[1, 1]], #2,
argStart, "\\int", argEnd,
escChar, #2,
argStart, escChar, "int", argEnd,
argStart, makeString[scr], argEnd
]
]
Expand All @@ -1701,13 +1709,14 @@ cell form (String or None)."
SubsuperscriptBox["\[Integral]", sub_, sup_, OptionsPattern[]] :>
With[
{
escChar = $commandCharsToTeX[[1, 1]],
argStart = $commandCharsToTeX[[2, 1]],
argEnd = $commandCharsToTeX[[3, 1]]
}
,
StringJoin[
$commandCharsToTeX[[1, 1]], "mmaSubSupM",
argStart, "\\int", argEnd,
escChar, "mmaSubSupM",
argStart, escChar, "int", argEnd,
argStart, makeString[sub], argEnd,
argStart, makeString[sup], argEnd
]
Expand Down Expand Up @@ -1837,7 +1846,11 @@ cell form (String or None)."
characterRules,
{1}
],
"\\)\\(" -> ""
StringJoin[
$commandCharsToTeX[[1, 1]], ")",
$commandCharsToTeX[[1, 1]], "("
] ->
""
]
}
]
Expand Down Expand Up @@ -1875,7 +1888,14 @@ cell form (String or None)."
]
]
,
" " -> ""
With[{escChar = $commandCharsToTeX[[1, 1]]},
{
" " -> "",
"\\{" -> escChar <> "{", "{" -> $commandCharsToTeX[[2, 1]],
"\\}" -> escChar <> "}", "}" -> $commandCharsToTeX[[3, 1]],
"\\\\" -> "\\\\", "\\" -> escChar
}
]
]


Expand Down
32 changes: 19 additions & 13 deletions CellsToTeX/Tests/Integration/getBoxesToFormattedTeX.mt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ BeginPackage[

Get["CellsToTeX`"]

PrependTo[$ContextPath, "CellsToTeX`Configuration`"]

With[{boxRules = CellsToTeX`Configuration`getBoxesToFormattedTeX[]},

With[{boxRules = getBoxesToFormattedTeX[]},
tmpBoxesToString =
CellsToTeX`Internal`boxesToString[
#, boxRules, FormatType -> InputForm
Expand Down Expand Up @@ -68,12 +70,14 @@ Test[
TestID -> "}"
]

Test[
"\[Alpha]\[Beta]\[Gamma]" // tmpBoxesToString
,
"\\(\\alpha\\beta\\gamma\\)"
,
TestID -> "\\[Alpha]\\[Beta]\\[Gamma]"
Block[{$commandCharsToTeX = {"&" -> "test1", "[" -> "test2", "]" -> "test3"}},
Test[
"\[Alpha]\[Beta]\[Gamma]" // tmpBoxesToString
,
"&(&alpha&beta&gamma&)"
,
TestID -> "\\[Alpha]\\[Beta]\\[Gamma]"
]
]


Expand Down Expand Up @@ -107,12 +111,14 @@ Test[
,
TestID -> "SubscriptBox: with option"
]
Test[
SubscriptBox["\[Integral]", "a"] // tmpBoxesToString
,
"\\mmaSubM{\\int}{a}"
,
TestID -> "SubscriptBox: \\[Integral]"
Block[{$commandCharsToTeX = {"!" -> "test1", "(" -> "test2", ")" -> "test3"}},
Test[
SubscriptBox["\[Integral]", "a"] // tmpBoxesToString
,
"!mmaSubM(!int)(a)"
,
TestID -> "SubscriptBox: \\[Integral]: command chars"
]
]

Test[
Expand Down
58 changes: 31 additions & 27 deletions CellsToTeX/Tests/Unit/annotationRulesToBoxRules.mt
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,40 @@ $ContextPath =
(*Tests*)


TestMatch[
{"type" -> {"key", "comand"}} // annotationRulesToBoxRules
,
{
SyntaxBox[
Verbatim[Pattern][boxes_, Verbatim[_]], "type", Verbatim[___]
] :>
"\\comand{" <> makeString[boxes_] <> "}"
}
,
TestID -> "1 rule"
Block[{$commandCharsToTeX = {"%" -> "%%", "<" -> "%<", ">" -> "%>"}},
TestMatch[
{"type" -> {"key", "comand"}} // annotationRulesToBoxRules
,
{
SyntaxBox[
Verbatim[Pattern][boxes_, Verbatim[_]], "type", Verbatim[___]
] :>
"%comand<" <> makeString[boxes_] <> ">"
}
,
TestID -> "1 rule"
]
]

TestMatch[
{"type1" -> {"key1", "comand1"}, "type2" -> {"key2", "comand2"}} //
annotationRulesToBoxRules
,
{
SyntaxBox[
Verbatim[Pattern][boxes_, Verbatim[_]], "type1", Verbatim[___]
] :>
"\\comand1{" <> makeString[boxes_] <> "}"
Block[{$commandCharsToTeX = {"\\" -> "test1", "{" -> "test2", "}" -> "test3"}},
TestMatch[
{"type1" -> {"key1", "comand1"}, "type2" -> {"key2", "comand2"}} //
annotationRulesToBoxRules
,
SyntaxBox[
Verbatim[Pattern][boxes_, Verbatim[_]], "type2", Verbatim[___]
] :>
"\\comand2{" <> makeString[boxes_] <> "}"
}
,
TestID -> "2 rules"
{
SyntaxBox[
Verbatim[Pattern][boxes_, Verbatim[_]], "type1", Verbatim[___]
] :>
"\\comand1{" <> makeString[boxes_] <> "}"
,
SyntaxBox[
Verbatim[Pattern][boxes_, Verbatim[_]], "type2", Verbatim[___]
] :>
"\\comand2{" <> makeString[boxes_] <> "}"
}
,
TestID -> "2 rules"
]
]


Expand Down
14 changes: 8 additions & 6 deletions CellsToTeX/Tests/Unit/charToTeX.mt
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ PrependTo[$ContextPath, "CellsToTeX`Configuration`"]
(*Tests*)


Test[
charToTeX["\[PlusMinus]"]
,
"\\(\\pm\\)"
,
TestID -> "\[PlusMinus]"
Block[{$commandCharsToTeX = {"?" -> "test1", "[" -> "test2", "]" -> "test3"}},
Test[
charToTeX["\[PlusMinus]"]
,
"?(?pm?)"
,
TestID -> "\[PlusMinus]"
]
]


Expand Down
6 changes: 5 additions & 1 deletion CellsToTeX/Tests/Unit/getBoxesToFormattedTeX.mt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ TestMatch[
{testChar -> testCharReplacement},
{1}
],
"\\)\\(" -> ""
StringJoin[
$commandCharsToTeX[[1, 1]], ")",
$commandCharsToTeX[[1, 1]], "("
] ->
""
]
}
,
Expand Down