diff --git a/crates/marknest-core/src/lib.rs b/crates/marknest-core/src/lib.rs index ee9a33a..003ec93 100644 --- a/crates/marknest-core/src/lib.rs +++ b/crates/marknest-core/src/lib.rs @@ -1776,9 +1776,9 @@ fn build_html_document(title: &str, body_html: &str, options: &RenderOptions) -> fn sanitize_html_fragment(html_fragment: &str) -> String { let mut sanitizer = HtmlSanitizerBuilder::default(); sanitizer.url_relative(UrlRelative::PassThrough); - sanitizer.add_generic_attributes(["aria-label", "class", "id", "title"]); + sanitizer.add_generic_attributes(["align", "aria-label", "class", "id", "title"]); sanitizer.add_tags(["details", "figure", "figcaption", "input", "nav", "summary"]); - sanitizer.add_tag_attributes("img", ["width", "height", "align", "loading"]); + sanitizer.add_tag_attributes("img", ["width", "height", "loading"]); sanitizer.add_tag_attributes("input", ["type", "checked", "disabled"]); sanitizer.add_tag_attributes("details", ["open"]); sanitizer.clean(html_fragment).to_string() diff --git a/crates/marknest-core/tests/fixtures/workspace_align_center/README.md b/crates/marknest-core/tests/fixtures/workspace_align_center/README.md new file mode 100644 index 0000000..31e9db1 --- /dev/null +++ b/crates/marknest-core/tests/fixtures/workspace_align_center/README.md @@ -0,0 +1,13 @@ +
+
+
+A short description of the project. +
+ +## Features + +- Feature one diff --git a/crates/marknest-core/tests/render_workspace_html.rs b/crates/marknest-core/tests/render_workspace_html.rs index d968178..06bc3da 100644 --- a/crates/marknest-core/tests/render_workspace_html.rs +++ b/crates/marknest-core/tests/render_workspace_html.rs @@ -365,6 +365,23 @@ fn sanitizes_raw_html_by_default_while_preserving_safe_readme_markup() { assert!(rendered.html.contains("data:image/svg+xml;base64,")); } +#[test] +fn preserves_align_attribute_on_block_elements() { + let rendered = render_workspace_entry(&fixture_path("workspace_align_center"), "README.md") + .expect("workspace entry should render"); + + assert!( + rendered.html.contains("align=\"center\""), + "align attribute onshould be preserved; got: {}", + rendered.html + ); + assert!( + rendered.html.contains("