Fix rust fenced code blocks with an indent

This fixes a bug in the Rust code block partitioning that was
incorrectly removing the whitespace from the beginning of a code block.
This commit is contained in:
Eric Huss 2025-10-27 18:38:27 -07:00
parent 3992bc18f5
commit ddf02e0c0c
2 changed files with 11 additions and 4 deletions

View file

@ -141,8 +141,15 @@ fn partition_rust_source(s: &str) -> (&str, &str) {
let split_idx = match HEADER_RE.captures(s) { let split_idx = match HEADER_RE.captures(s) {
Some(caps) => { Some(caps) => {
let attributes = &caps[1]; let attributes = &caps[1];
if attributes.trim().is_empty() {
// Don't include pure whitespace as an attribute. The
// whitespace in the regex is intended to handle multiple
// attributes *separated* by potential whitespace.
0
} else {
attributes.len() attributes.len()
} }
}
None => 0, None => 0,
}; };
s.split_at(split_idx) s.split_at(split_idx)