Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions crates/core/src/document/html/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1504,6 +1504,11 @@ impl Engine {
(plan.glyph_advance(1), 3 * plan.glyph_advance(0))
};

// The merge range spans the whole token, so that the
// punctuation boxes split off below are glued back to
// their word by `cleanup_paragraph`.
let token_start = hyph_items.len();

let mut index_before = text.find(char::is_alphabetic).unwrap_or_else(|| text.len());
if index_before > 0 {
let subelem = self.box_from_chunk(&text[0..index_before],
Expand All @@ -1518,7 +1523,6 @@ impl Engine {
while index_before < index_after {
let mut index = 0;
let chunk = &text[index_before..index_after];
let len_before = hyph_items.len();

for segment in dictionary.hyphenate(chunk).iter().segments() {
let subelem = self.box_from_chunk(segment,
Expand All @@ -1538,10 +1542,6 @@ impl Engine {
}
}

let len_after = hyph_items.len();
if len_after > 1 + len_before {
hyph_indices.push([len_before, len_after]);
}
index_before = text[index_after..].find(char::is_alphabetic)
.map(|i| index_after + i)
.unwrap_or_else(|| text.len());
Expand All @@ -1556,6 +1556,11 @@ impl Engine {
.map(|i| index_before + i)
.unwrap_or_else(|| text.len());
}

let token_end = hyph_items.len();
if token_end > 1 + token_start {
hyph_indices.push([token_start, token_end]);
}
},
_ => { hyph_items.push(itm) },
}
Expand Down