From d8855e24893ba7db97aaf7f94b054782a4276833 Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Sat, 31 Jan 2026 14:31:32 +1300 Subject: Auto-insert line breaks for environment-free math fragments This was an important functionality for a lot of my math notes, so I've brought it back, but only if the math syntax fragment doesn't contain a '\begin', which denotes the sort of advanced environment where automatic line breaks are not welcome. --- src/generate_html.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/generate_html.rs') diff --git a/src/generate_html.rs b/src/generate_html.rs index 36f3325..7bec912 100644 --- a/src/generate_html.rs +++ b/src/generate_html.rs @@ -239,7 +239,13 @@ pub fn document_to_html(page: &Page, website: &Website) -> String { } Block::Fragment { language, content } => { match language.as_str() { - "math" => html!("
{content}
"), + "math" => { + let mut content = content.trim().to_string(); + if !content.contains(r"\begin") { + content = content.replace("\n", " \\\\\n").to_string(); + } + html!("
{content}
") + }, "embed-html" => html!("{content}"), "embed-css" => wrap!("style", html!("{content}")), "embed-javascript"|"embed-js" => wrap!("script", html!("{content}")), -- cgit v1.2.3-70-g09d2