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
@@ -120,6 +120,8 @@ struct Run {
|
||||
named: HashMap<String, usize>,
|
||||
/// Inside an autolink: its text stays as written.
|
||||
verbatim: bool,
|
||||
/// In a table cell, whose code reads `\|` as `|`.
|
||||
table: bool,
|
||||
/// The current DOM text node's shortcodes.
|
||||
shortcodes: emoji::Shortcodes,
|
||||
/// White space owed, and the open elements before it.
|
||||
@@ -306,7 +308,10 @@ impl<'a> Reader<'a> {
|
||||
{
|
||||
return out.push(Node::Math(math.value.clone()));
|
||||
}
|
||||
let mut run = Run::default();
|
||||
let mut run = Run {
|
||||
table: matches!(node, mdast::Node::TableCell(_)),
|
||||
..Run::default()
|
||||
};
|
||||
for child in children {
|
||||
self.inline_into(child, &mut run, &mut Images::Split(out));
|
||||
}
|
||||
@@ -344,6 +349,11 @@ impl<'a> Reader<'a> {
|
||||
run.shortcodes.split();
|
||||
}
|
||||
if let Some((written, escapes)) = sources::written(node, self.source) {
|
||||
let escapes = match (escapes, node) {
|
||||
(Escapes::Markdown, _) if run.verbatim => Escapes::Plain,
|
||||
(_, mdast::Node::InlineCode(_)) if run.table => Escapes::Pipes,
|
||||
_ => escapes,
|
||||
};
|
||||
let at = run.text.text.len();
|
||||
run.text.sources.push((at, written, escapes));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user