summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAna Gelez <ana+github@gelez.xyz>2024-03-25 14:32:02 +0100
committerGitHub <noreply@github.com>2024-03-25 13:32:02 +0000
commit2efa86cbdf3e60602fe5524aeaa0befdf14eafcf (patch)
tree99b72aba2ee47fdc1b20ea714eec826c4179af41 /crates
parenta33d8bf32208ef0fe8556200dd0c9c5a1ad10c54 (diff)
Fix smart quotes in PDF outline (#3790)
Diffstat (limited to 'crates')
-rw-r--r--crates/typst/src/text/smartquote.rs16
1 files changed, 14 insertions, 2 deletions
diff --git a/crates/typst/src/text/smartquote.rs b/crates/typst/src/text/smartquote.rs
index dbcca6dc..4bb5ca01 100644
--- a/crates/typst/src/text/smartquote.rs
+++ b/crates/typst/src/text/smartquote.rs
@@ -2,7 +2,9 @@ use ecow::EcoString;
use unicode_segmentation::UnicodeSegmentation;
use crate::diag::{bail, StrResult};
-use crate::foundations::{array, cast, dict, elem, Array, Dict, FromValue, Smart, Str};
+use crate::foundations::{
+ array, cast, dict, elem, Array, Dict, FromValue, Packed, PlainText, Smart, Str,
+};
use crate::layout::Dir;
use crate::syntax::is_newline;
use crate::text::{Lang, Region};
@@ -26,7 +28,7 @@ use crate::text::{Lang, Region};
/// # Syntax
/// This function also has dedicated syntax: The normal quote characters
/// (`'` and `"`). Typst automatically makes your quotes smart.
-#[elem(name = "smartquote")]
+#[elem(name = "smartquote", PlainText)]
pub struct SmartQuoteElem {
/// Whether this should be a double quote.
#[default(true)]
@@ -85,6 +87,16 @@ pub struct SmartQuoteElem {
pub quotes: Smart<SmartQuoteDict>,
}
+impl PlainText for Packed<SmartQuoteElem> {
+ fn plain_text(&self, text: &mut EcoString) {
+ if self.double.unwrap_or(true) {
+ text.push_str("\"");
+ } else {
+ text.push_str("'");
+ }
+ }
+}
+
/// State machine for smart quote substitution.
#[derive(Debug, Clone)]
pub struct SmartQuoter {