summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYip Coekjan <69834864+Coekjan@users.noreply.github.com>2024-10-08 16:37:11 +0800
committerLaurenz <laurmaedje@gmail.com>2024-10-15 15:06:36 +0200
commitf8a218f59755e83d215f035c942c122fcef27abd (patch)
tree1fd3a53c2d22b6f7896efd1138205623f8278040
parent49154d844213c8abdb10480866912c1a746492e4 (diff)
Fix smartquotes after inline equations (#5149)
-rw-r--r--crates/typst/src/text/smartquote.rs9
-rw-r--r--tests/ref/issue-5146-smartquotes-after-equations.pngbin0 -> 240 bytes
-rw-r--r--tests/suite/text/smartquote.typ3
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
new file mode 100644
index 00000000..96be7204
--- /dev/null
+++ b/tests/ref/issue-5146-smartquotes-after-equations.png
Binary files differ
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