From f8a218f59755e83d215f035c942c122fcef27abd Mon Sep 17 00:00:00 2001 From: Yip Coekjan <69834864+Coekjan@users.noreply.github.com> Date: Tue, 8 Oct 2024 16:37:11 +0800 Subject: [PATCH] Fix smartquotes after inline equations (#5149) --- crates/typst/src/text/smartquote.rs | 9 ++++++--- .../issue-5146-smartquotes-after-equations.png | Bin 0 -> 240 bytes tests/suite/text/smartquote.typ | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 tests/ref/issue-5146-smartquotes-after-equations.png diff --git a/crates/typst/src/text/smartquote.rs b/crates/typst/src/text/smartquote.rs index 9b48c03ac..467165b6a 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 new file mode 100644 index 0000000000000000000000000000000000000000..96be7204a0b86a56c67338bca6e5688d578a5f75 GIT binary patch literal 240 zcmV1cY(Unlq-E+^;+TxYVmIBGUxo@@s{l3i$BKRcj!zP*sb?{qILcfaKYq^Xh?A&7sp^!3*D(mebneH-&qEp-f1#wW1g qf$IKCqb1j<#iJIFT0Cko7ytmdpoEJ~;ed?*0000