Documents: code protection closes and reopens tags as the reader does
CI / site (push) Successful in 33s
CI / platforms (windows-latest) (push) Successful in 5m1s
CI / crate (push) Failing after 11m3s
CI / platforms (ubuntu-24.04) (push) Canceled after 0s

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude committed 2026-10-19 00:24:40 -04:00
1 parent 5fba7b3dfb
commit de961eb164
2 files changed
+56 -12

No files matched your search

+21
View File
@@ -86,6 +86,27 @@ fn code_and_tags_stay_literal() {
untouched(r"a <code><code>\(x\)</code> \(y\)</code> b");
untouched(r"a <kbd><code>\(x\)</code> \(y\)</kbd> b");
assert_eq!(tex(r"<code>a</code> \(x\)"), ["x"], "after code, prose");
for crossed in [
r"a <code><kbd>x</code> \(y\) b",
r"a <b><kbd>x</b> \(y\) b",
r"a <code><b>x</code> \(y\)</b> b",
] {
assert_eq!(
tex(crossed),
["y"],
"a crossed close ends code: {crossed:?}"
);
}
untouched(r"a <b><code>x</b> \(y\) b");
let reopened = crate::documents::tree::parse(r"a <b><code>x</b> \(y\) b");
let crate::documents::tree::Node::Paragraph(inline) = &reopened[0] else {
panic!("a paragraph: {reopened:?}");
};
let code = crate::documents::tree::Style::Code;
assert!(
(inline.styles.iter()).any(|(range, style)| *style == code && range.contains(&6)),
"the reader reopens code over (y): {inline:?}"
);
untouched(r"`\(x\)`");
untouched(r"\(a `b` c\)");
assert_eq!(tex(r"<b>\(x\)</b>"), ["x"], "other tags hold prose");