documents: read presses as the parser decoded them
Round 3 of R4.5 found five ways the reverse reading drifted from markdown-rs: kept indents and marks were eaten as joins, autolink text was decoded, table code kept its escaped pipes, decoded white space could not join or drop, and C0/C1 numeric references kept their controls. Matching now tries an equal character first, a drawn space against any line end next, and drops white space decoded or not; autolinks read as written, table cell code reads \| as |, and numeric references follow markdown-rs. The reviewer's probes are regressions. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
d4c614cb7f
commit
c35fdac2e3
7 files changed
+223
-32
No files matched your search
@@ -121,3 +121,61 @@ fn a_decoded_line_end_reads_without_a_written_one() {
|
||||
let alert = parsed("> [!NOTE] alpha beta");
|
||||
assert_eq!(alert.blocks[0].kind, TargetBlock::Alert);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn kept_leading_marks_still_map() {
|
||||
let source = "a `fox\n y` z";
|
||||
assert_eq!(read_back(source, "ox"), source.find("ox"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn decoded_line_end_maps_nearby_text() {
|
||||
for (source, shown) in [
|
||||
("ab y", "b"),
|
||||
("ab y", "b"),
|
||||
("ab 
 y", "b"),
|
||||
("<div>ab y</div>", "b"),
|
||||
("<div>ab 	 y</div>", "b"),
|
||||
] {
|
||||
assert_eq!(read_back(source, shown), source.find(shown), "{source:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn numeric_references_match_the_parser() {
|
||||
for source in ["ab € y", "ab  y", "ab  y"] {
|
||||
assert_eq!(read_back(source, "b"), source.find('b'), "{source:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn html_trailing_encoded_space_maps_previous_word() {
|
||||
for source in [
|
||||
"<div>ab </div>",
|
||||
"<div>ab <b>word</b></div>",
|
||||
"<div>ab   word</div>",
|
||||
] {
|
||||
assert_eq!(read_back(source, "b"), source.find('b'), "{source:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn code_pipe_in_a_table_maps_previous_text() {
|
||||
let source = "| `ab\\|cd` |\n| --- |\n| cell |\n";
|
||||
let parsed = parsed(source);
|
||||
let nodes = parsed.blocks[0].nodes.as_ref().unwrap();
|
||||
let Node::Table { head, .. } = &nodes[0] else {
|
||||
panic!("table")
|
||||
};
|
||||
let Node::Paragraph(inline) = &head[0][0] else {
|
||||
panic!("text")
|
||||
};
|
||||
assert_eq!(inline.text, "ab|cd");
|
||||
assert_eq!(inline.source_at(source, 1), source.find('b'));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn autolink_does_not_decode_literal_reference() {
|
||||
let source = "<https://example.com/?a=&b=2>";
|
||||
assert_eq!(read_back(source, "xample"), source.find("xample"));
|
||||
}
|
||||
Reference in new issue
Block a user