Skip to content

Commit 058dc53

Browse files
committed
more consistency fixes
1 parent 86477f6 commit 058dc53

File tree

2 files changed

+14
-1
lines changed
  • crates/quarto-markdown-pandoc

2 files changed

+14
-1
lines changed

crates/quarto-markdown-pandoc/src/pandoc/treesitter_utils/postprocess.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,10 @@ pub fn coalesce_abbreviations(inlines: Vec<Inline>) -> (Vec<Inline>, bool) {
135135

136136
// Check if current text ends with an abbreviation
137137
if ends_with_abbreviation(&current_text) {
138+
let original_j = j;
138139
// Coalesce with following Space + Str
139140
while j + 1 < inlines.len() {
140-
if let (Inline::Space(_), Inline::Str(next_str)) =
141+
if let (Inline::Space(_space_info), Inline::Str(next_str)) =
141142
(&inlines[j], &inlines[j + 1])
142143
{
143144
// Coalesce with non-breaking space (U+00A0) to match Pandoc
@@ -156,6 +157,17 @@ pub fn coalesce_abbreviations(inlines: Vec<Inline>) -> (Vec<Inline>, bool) {
156157
break;
157158
}
158159
}
160+
161+
// If we didn't coalesce with any Str nodes but have a Space following
162+
// the abbreviation, include the space in the abbreviation to match Pandoc
163+
if j == original_j && j < inlines.len() && matches!(inlines[j], Inline::Space(_)) {
164+
if let Inline::Space(space_info) = &inlines[j] {
165+
current_text.push('\u{00A0}');
166+
end_info = space_info.source_info.clone();
167+
j += 1;
168+
did_coalesce = true;
169+
}
170+
}
159171
}
160172

161173
// Create the Str node (possibly coalesced)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
e.g. `code`

0 commit comments

Comments
 (0)