Treat tildes as spaces outside URLs
This commit is contained in:
1 parent
994c360ec0
commit
e6a12fae9a
4 files changed
+20
-6
No files matched your search
+16
-2
@@ -715,7 +715,7 @@ fn expand_links_line(line: &str) -> String {
|
||||
continue;
|
||||
};
|
||||
output.push_str("\\texttt{");
|
||||
output.push_str(&target);
|
||||
output.push_str(&target.replace('~', "\\textasciitilde{}"));
|
||||
output.push('}');
|
||||
rest = &after[used..];
|
||||
}
|
||||
@@ -6804,6 +6804,7 @@ fn inline_math_segments(
|
||||
match part {
|
||||
HrefPart::Plain(piece) => {
|
||||
for (color, background, frame, chunk) in split_color_runs(&piece, custom) {
|
||||
let chunk = chunk.replace('~', " ");
|
||||
let runs = inline_styled_runs(&chunk, base)
|
||||
.unwrap_or_else(|| vec![(base, style.font_size, 0, chunk.clone())]);
|
||||
for (font, size, raise, run_text) in runs {
|
||||
@@ -8875,7 +8876,7 @@ fn build_document_with_labels(
|
||||
space_skip: geometry.space_skip,
|
||||
xspace_skip: geometry.xspace_skip,
|
||||
};
|
||||
let plain = strip_hrefs(&text);
|
||||
let plain = strip_hrefs(&text).replace('~', " ");
|
||||
let mut unit = match inline_math_segments(
|
||||
&text,
|
||||
paragraph.font,
|
||||
@@ -12793,6 +12794,19 @@ A definition.
|
||||
assert_eq!(runs[0].3, "Boxed");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tildes_make_spaces() {
|
||||
let json = preview_json("Figure~1.").expect("preview");
|
||||
assert!(!json.contains(">~</text>"), "{json}");
|
||||
assert!(json.contains(">F</text>"), "{json}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn url_tildes_stay_literal() {
|
||||
let json = preview_json(r"\url{https://x.test/a~b}").expect("preview");
|
||||
assert!(json.contains(">~</text>"), "{json}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fbox_draws_a_frame_without_a_background() {
|
||||
let json = preview_json(r"\fbox{Boxed}").expect("preview");
|
||||
|
||||
Reference in new issue
Block a user