diff options
| author | Fuwn <[email protected]> | 2025-05-21 08:56:46 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-05-21 08:56:46 +0000 |
| commit | 596c583dc659f9e56768602f98fd8da6d9434423 (patch) | |
| tree | df5fb35d2fb80921c974c5dded35c1d485bedcfd | |
| parent | refactor(src): Remove unnecessary allocations (diff) | |
| download | september-596c583dc659f9e56768602f98fd8da6d9434423.tar.xz september-596c583dc659f9e56768602f98fd8da6d9434423.zip | |
fix(html): Escape nested list items in headings
| -rw-r--r-- | src/html.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/html.rs b/src/html.rs index 609be98..2fd0dc3 100644 --- a/src/html.rs +++ b/src/html.rs @@ -10,9 +10,16 @@ fn link_from_host_href(url: &Url, href: &str) -> Option<String> { } fn safe(text: &str) -> String { - comrak::markdown_to_html(text, &comrak::ComrakOptions::default()) - .replace("<p>", "") - .replace("</p>", "") + let is_ordered_list = text.starts_with(|c: char| c.is_ascii_digit()) + && text.get(1..3) == Some(". "); + + if is_ordered_list { + text.to_string() + } else { + comrak::markdown_to_html(text, &comrak::ComrakOptions::default()) + .replace("<p>", "") + .replace("</p>", "") + } } #[allow(clippy::too_many_lines, clippy::cognitive_complexity)] |