Skip to content

Commit de2c4a1

Browse files
committed
Fix indented admonitions
This fixes the formatting for admonitions when they are indented. The code was missing the indentation for the parts that it was adding, which made it overall inconsistent and fail to render correctly.
1 parent 65c7bc2 commit de2c4a1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

mdbook-spec/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,15 @@ impl Spec {
133133
let lower = caps["admon"].to_lowercase();
134134
let term = to_initial_case(&caps["admon"]);
135135
let blockquote = &caps["blockquote"];
136+
let initial_spaces = blockquote.chars().position(|ch| ch != ' ').unwrap_or(0);
137+
let space = &blockquote[..initial_spaces];
136138
format!(
137-
"<div class=\"{lower}\">\n\
139+
"{space}<div class=\"{lower}\">\n\
138140
\n\
139-
> ***{term}:***\n\
141+
{space}> ***{term}:***\n\
140142
{blockquote}\n\
141143
\n\
142-
</div>\n",
144+
{space}</div>\n",
143145
)
144146
})
145147
.to_string()

0 commit comments

Comments
 (0)