From 47657508e03f8e082e1a94bb25576e1dcbf73571 Mon Sep 17 00:00:00 2001 From: "K.B.Dharun Krishna" Date: Tue, 21 Jan 2025 17:57:39 +0530 Subject: [PATCH 1/2] Enable Comrak support for style alerts in Markdown Signed-off-by: K.B.Dharun Krishna --- crates/crates_io_markdown/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/crates_io_markdown/lib.rs b/crates/crates_io_markdown/lib.rs index 6a204a71a2d..663864dcb5e 100644 --- a/crates/crates_io_markdown/lib.rs +++ b/crates/crates_io_markdown/lib.rs @@ -77,7 +77,9 @@ impl<'a> MarkdownRenderer<'a> { .build(); let extension_options = ComrakExtensionOptions::builder() + .alerts(true) .autolink(true) + .multiline_block_quotes(true) .strikethrough(true) .table(true) .tagfilter(true) From 0e76b2a246da49ddfad1f54ffa0465f32a47cb1c Mon Sep 17 00:00:00 2001 From: "K.B.Dharun Krishna" Date: Wed, 5 Feb 2025 00:21:14 +0530 Subject: [PATCH 2/2] feat: add test cases Signed-off-by: K.B.Dharun Krishna --- crates/crates_io_markdown/lib.rs | 26 +++++++++++++++++++++++ tests/acceptance/readme-rendering-test.js | 16 ++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/crates/crates_io_markdown/lib.rs b/crates/crates_io_markdown/lib.rs index 663864dcb5e..b3ec061d0c1 100644 --- a/crates/crates_io_markdown/lib.rs +++ b/crates/crates_io_markdown/lib.rs @@ -672,4 +672,30 @@ There can also be some text in between! "#); } + + #[test] + fn markdown_alerts() { + let text = "> [!note]\n> Something of note"; + assert_snapshot!(markdown_to_html(text, None, ""), @r#" +
+

Note

+

Something of note

+
+ "#); + } + + #[test] + fn markdown_multiline_block_quotes_complex() { + let text = "Paragraph one\n\n>>>\nParagraph two\n\n- one\n- two\n>>>"; + assert_snapshot!(markdown_to_html(text, None, ""), @r#" +

Paragraph one

+
+

Paragraph two

+
    +
  • one
  • +
  • two
  • +
+
+ "#); + } } diff --git a/tests/acceptance/readme-rendering-test.js b/tests/acceptance/readme-rendering-test.js index db6d8cb48ce..fdaf191415b 100644 --- a/tests/acceptance/readme-rendering-test.js +++ b/tests/acceptance/readme-rendering-test.js @@ -66,6 +66,22 @@ graph TD; C-->D; +

GitHub Style Alert

+
+

Note

+

Something of note

+
+ +

GitLab Style Multiline Block Quotes

+

Paragraph one

+
+

Paragraph two

+
    +
  • one
  • +
  • two
  • +
+
+
  • Delegate to a method with a different name