Skip to content

Commit

Permalink
Add extra characters to Typst escapes
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHatherly committed Nov 27, 2024
1 parent 9b8df31 commit 2a714a6
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Add extra escape characters to Typst [#54](https://github.com/PumasAI/SummaryTables.jl/pull/54).

## 3.0.1 - 2024-10-24

- Added single-argument method to `table_one` which summarizes all columns in the passed table except those used for grouping [#48](https://github.com/PumasAI/SummaryTables.jl/pull/48).
Expand Down
2 changes: 1 addition & 1 deletion src/typst.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function _showas(io::IO, ::MIME"text/typst", s::Subscript)
end

function _str_typst_escaped(io::IO, s::AbstractString)
escapable_special_chars = raw"\$#*_"
escapable_special_chars = raw"\$#*_<@\\`"
a = Iterators.Stateful(s)
for c in a
if c in escapable_special_chars
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
</w:pPr>
<w:r>
<w:rPr/>
<w:t xml:space="preserve">&amp; % $ # _ { } ~ ^ \ &lt; &gt; " ' </w:t>
<w:t>&amp; % $ # _ { } ~ ^ \ &lt; &gt; " ' @ `</w:t>
</w:r>
</w:p>
</w:tc>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
\begin{threeparttable}
\begin{tabular}{@{\extracolsep{2ex}}*{1}{c}}
\toprule
\& \% \$ \# \_ \{ \} \textasciitilde{} \textasciicircum{} \textbackslash{} < > " ' \\
\& \% \$ \# \_ \{ \} \textasciitilde{} \textasciicircum{} \textbackslash{} < > " ' @ ` \\
\bottomrule
\end{tabular}
\end{threeparttable}
Expand Down
14 changes: 7 additions & 7 deletions test/references/character_escaping/problematic_characters.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<table class="st-4d26b3b4">
<table class="st-10cadcb1">
<style>
.st-4d26b3b4 {
.st-10cadcb1 {
border: none;
margin: 0 auto;
padding: 0.25rem;
Expand All @@ -9,28 +9,28 @@
line-height: 1.2em;
}

.st-4d26b3b4 tr td {
.st-10cadcb1 tr td {
vertical-align: top;
padding: 0;
border: none;
}

.st-4d26b3b4 br {
.st-10cadcb1 br {
line-height: 0em;
margin: 0;
}

.st-4d26b3b4 sub {
.st-10cadcb1 sub {
line-height: 0;
}

.st-4d26b3b4 sup {
.st-10cadcb1 sup {
line-height: 0;
}
</style>
<tr><td colspan="1" style="border-bottom: 1.5px solid black; padding: 0"></td></tr>
<tr>
<td style="text-align:center;">&amp; % $ # _ { } ~ ^ \\ &lt; &gt; &quot; &apos; </td>
<td style="text-align:center;">&amp; % $ # _ { } ~ ^ \\ &lt; &gt; &quot; &apos; @ `</td>
</tr>
<tr><td colspan="1" style="border-bottom: 1.5px solid black; padding: 0"></td></tr>
</table>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
align: (center),
stroke: none,
table.hline(y: 0, stroke: 1pt),
[& % \$ \# \_ { } ~ ^ \\ < > " ' ],
[& % \$ \# \_ { } ~ ^ \\ \< > " ' \@ \`],
table.hline(y: 1, stroke: 1pt),
)
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ end

@testset "Character escaping" begin
cells = [
SpannedCell(1, 1, "& % \$ # _ { } ~ ^ \\ < > \" ' ")
SpannedCell(1, 1, "& % \$ # _ { } ~ ^ \\ < > \" ' @ `")
]
t = Table(
cells,
Expand Down

0 comments on commit 2a714a6

Please sign in to comment.