Skip to content

Commit 7addb2d

Browse files
committed
fix: keep the extension of long Typst filenames attached
1 parent 878768f commit 7addb2d

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

‎src/resources/formats/typst/pandoc/quarto/definitions.typ‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,13 @@
6060
}
6161

6262
#let quarto-code-filename(filename, body) = {
63-
// Long names would be clipped: allow breaks after separators first, and
63+
// Long names would be clipped: allow breaks after separators (but not after the
64+
// last dot, which keeps the extension attached) first, and
6465
// inside runs of more than 30 characters without a separator
6566
let filename = if type(filename) == str and filename.len() > 40 {
6667
filename
6768
.replace(regex("[/_.-]"), m => m.text + "\u{200b}")
69+
.replace(regex("\\.\u{200b}([^.]*)\\z"), m => "." + m.captures.at(0))
6870
.replace(regex("[^/_.\u{200b}-]{31,}"), m => m.text.clusters().join("\u{200b}"))
6971
} else { filename }
7072
show raw.where(block: true): it => it

‎tests/docs/smoke-all/typst/code-filename/edge/e06-special.qmd‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ _quarto:
1414
- 'quarto-code-filename\("e\*f_g\.py"'
1515
- 'quarto-code-filename\("123"'
1616
- 'replace\(regex\("\[/_\.-\]"\), m => m\.text \+ "\\u\{200b\}"\)'
17+
- 'replace\(regex\("\\\\\.\\u\{200b\}\(\[\^\.\]\*\)\\\\z"\)'
1718
- 'replace\(regex\("\[\^/_\.\\u\{200b\}-\]\{31,\}"\)'
1819
- []
1920
---

0 commit comments

Comments
 (0)