Skip to content

Commit

Permalink
support monetary symbols (\$, \pounds, \yen)
Browse files Browse the repository at this point in the history
  • Loading branch information
qwinsi committed Aug 16, 2024
1 parent a6e7946 commit 954aa79
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ export const symbolMap = new Map<string, string>([
['phi', 'phi.alt'],
['pi', 'pi'],
['pm', 'plus.minus'],
['pounds', 'pound'],
['prec', 'prec'],
['preceq', 'prec.eq'],
['prime', 'prime'],
Expand Down Expand Up @@ -289,5 +290,6 @@ export const symbolMap = new Map<string, string>([
['wedge', 'and'],
['wr', 'wreath'],
['xi', 'xi'],
['yen', 'yen'],
['zeta', 'zeta'],
]);
2 changes: 2 additions & 0 deletions src/writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ function convertToken(token: string): string {
return token;
} else if (token === '\\\\') {
return '\\\n';
} else if (token === '\\$') {
return token;
} else if (token.startsWith('\\')) {
const symbol = token.slice(1);
if (symbolMap.has(symbol)) {
Expand Down
2 changes: 2 additions & 0 deletions test/cheat-sheet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ perp = "perp"
phi = "phi.alt"
pi = "pi"
pm = "plus.minus"
pounds = "pound"
prec = "prec"
preceq = "prec.eq"
prime = "prime"
Expand Down Expand Up @@ -270,4 +271,5 @@ wedge = "and"
# wp = # not supported by Typst
wr = "wreath"
xi = "xi"
yen = "yen"
zeta = "zeta"
3 changes: 3 additions & 0 deletions test/symbol.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ cases:
# - title: def eq
# tex: \overset{\text{def}}{=}
# typst: eq.def
- title: monetary symbols
tex: \$ \pounds \yen
typst: \$ pound yen
- title: combinatorial number
tex: \binom{n}{k}
typst: binom(n, k)
Expand Down

0 comments on commit 954aa79

Please sign in to comment.