diff options
| author | Yip Coekjan <69834864+Coekjan@users.noreply.github.com> | 2024-10-08 16:37:11 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-08 08:37:11 +0000 |
| commit | 7a96c86487fe2eb35d88bd8314b26feec6118898 (patch) | |
| tree | ffa0ae8cc5138b9f46002c23b66e03b67e847fcf | |
| parent | 037c0c82160088f5f8026e2b6808db20c874e8ad (diff) | |
Fix smartquotes after inline equations (#5149)
| -rw-r--r-- | crates/typst/src/text/smartquote.rs | 9 | ||||
| -rw-r--r-- | tests/ref/issue-5146-smartquotes-after-equations.png | bin | 0 -> 240 bytes | |||
| -rw-r--r-- | tests/suite/text/smartquote.typ | 3 |
3 files changed, 9 insertions, 3 deletions
diff --git a/crates/typst/src/text/smartquote.rs b/crates/typst/src/text/smartquote.rs index 9b48c03a..467165b6 100644 --- a/crates/typst/src/text/smartquote.rs +++ b/crates/typst/src/text/smartquote.rs @@ -131,9 +131,12 @@ impl SmartQuoter { } // If we have a single smart quote, didn't recently open a single - // quotation, and are after an alphabetic char, interpret this as an - // apostrophe. - if !double && opened != Some(false) && before.is_alphabetic() { + // quotation, and are after an alphabetic char or an object (e.g. a + // math equation), interpret this as an apostrophe. + if !double + && opened != Some(false) + && (before.is_alphabetic() || before == '\u{FFFC}') + { return "’"; } diff --git a/tests/ref/issue-5146-smartquotes-after-equations.png b/tests/ref/issue-5146-smartquotes-after-equations.png Binary files differnew file mode 100644 index 00000000..96be7204 --- /dev/null +++ b/tests/ref/issue-5146-smartquotes-after-equations.png diff --git a/tests/suite/text/smartquote.typ b/tests/suite/text/smartquote.typ index fe4e8c85..fe398b7a 100644 --- a/tests/suite/text/smartquote.typ +++ b/tests/suite/text/smartquote.typ @@ -165,3 +165,6 @@ Some people's thought on this would be #[#set smartquote(enabled: false); "stran "test"\ "test" + +--- issue-5146-smartquotes-after-equations --- +$i$'s $i$ 's |
