mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-11 21:02:45 +00:00
Apply typographic quotes when xref format has an unterminated '<'
Found while testing crates/doc/src/xref.rs:~100 (expand, early `return out` in the `tag_end` None branch) Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f9cfd99adc
commit
88a45f5d58
1 file changed
+8
-1
@@ -101,7 +101,8 @@ pub fn expand(definition: &str, v: &XrefValues) -> String {
|
||||
out.push_str(&rest[..i]);
|
||||
let Some(j) = tag_end(&rest[i..]) else {
|
||||
out.push_str(&rest[i..]);
|
||||
return out;
|
||||
rest = "";
|
||||
break;
|
||||
};
|
||||
let tag = rest[i + 1..i + j].trim().trim_end_matches('/').trim();
|
||||
let name = tag.split_whitespace().next().unwrap_or("");
|
||||
@@ -452,6 +453,12 @@ mod tests {
|
||||
assert_eq!(expand("<partialPara delim=\">\" includeDelim=\"false\" />|", &v), "Intro |");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unterminated_lt_still_gets_typographic_quotes() {
|
||||
let v = XrefValues { para: "Intro".into(), ..Default::default() };
|
||||
assert_eq!(expand("\"<paraText />\" <", &v), "\u{201C}Intro\u{201D} <");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unterminated_quote_only_affects_its_own_tag() {
|
||||
let v = XrefValues { para: "Intro > the start".into(), ..Default::default() };
|
||||
|
||||
Reference in new issue
Block a user