diff options
| author | Ben Bridle <bridle.benjamin@gmail.com> | 2026-01-30 19:26:26 +1300 |
|---|---|---|
| committer | Ben Bridle <bridle.benjamin@gmail.com> | 2026-01-30 19:26:26 +1300 |
| commit | 200bb2c3c2af8f43d8403015198cc1932293b7bf (patch) | |
| tree | 3943a5c604e353f79c47a783eb03b175f5a98fee /src | |
| parent | fac075a91fef0ecac8ad1ca8c276ce3ccebd537b (diff) | |
| download | toaster-200bb2c3c2af8f43d8403015198cc1932293b7bf.zip | |
Improve smart-quote direction around punctuation
An apostrophe or quotation mark should point right (start a quote) if
it is preceded either by whitespace or a punctuation character.
Diffstat (limited to 'src')
| -rw-r--r-- | src/generate_html.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/generate_html.rs b/src/generate_html.rs index 6909871..36f3325 100644 --- a/src/generate_html.rs +++ b/src/generate_html.rs @@ -468,6 +468,8 @@ fn sanitize_text(text: &str, fancy: bool) -> String { true => chars[i + 1], false => ' ', }; + let is_whitespace = |c: char| c.is_whitespace() || "()[].,".contains(c); + match c { '&' => { // The HTML syntax for unicode characters is � @@ -477,14 +479,14 @@ fn sanitize_text(text: &str, fancy: bool) -> String { '<' => output.push_str("<"), '>' => output.push_str(">"), '"' => match fancy { - true => match prev.is_whitespace() { + true => match is_whitespace(prev) { true => output.push('“'), false => output.push('”'), } false => output.push_str("""), }, '\'' => match fancy { - true => match prev.is_whitespace() { + true => match is_whitespace(prev) { true => output.push('‘'), false => output.push('’'), } |
