Typst writer: escape hyphens when needed.

Closes #11334.
This commit is contained in:
John MacFarlane
2025-12-09 19:11:47 +01:00
parent c365deaf1f
commit b6339f9baa
3 changed files with 8 additions and 6 deletions
+6 -4
View File
@@ -584,11 +584,13 @@ escapeTypst smart context t =
| needsEscapeAtLineStart c || isOrderedListMarker t
-> afterBreak "\\"
_ -> mempty) <>
(literal (T.replace "//" "\\/\\/"
(if T.any needsEscape t
then T.concatMap escapeChar t
else t)))
literal (snd $ T.foldl' go ('\n', mempty) t)
where
go (lastc, t') c
| needsEscape c = (c, t' <> escapeChar c)
| c == '-', lastc == '-', smart = (c, t' <> T.pack ['\\',c])
| c == '/', lastc == '/' = (c, t' <> T.pack ['\\',c])
| otherwise = (c, T.snoc t' c)
escapeChar c
| c == '\160' = "~"
| c == '\8217', smart = "'" -- apostrophe
+1 -1
View File
@@ -16,7 +16,7 @@
% pandoc -f markdown-smart -t typst+smart
"don't do it---"
^D
\"don\'t do it---\"
\"don\'t do it-\-\-\"
```
```
+1 -1
View File
@@ -3,7 +3,7 @@
**Samsonov T.E.** Shape-Adaptive Geometric Simplification of Heterogeneous Line Datasets / T. E. Samsonov, O. P. Yakimova // International Journal of Geographical Information Science. — 2017. — Vol. 31. — № 8. — pp. 1485-1520.
^D
#strong[Samsonov T.E.] Shape-Adaptive Geometric Simplification of
Heterogeneous Line Datasets / T. E. Samsonov, O. P. Yakimova \/\/
Heterogeneous Line Datasets / T. E. Samsonov, O. P. Yakimova /\/
International Journal of Geographical Information Science. --- 2017. ---
Vol. 31. --- № 8. --- pp.~1485-1520.
```