Project

General

Profile

Actions

Feature #42603

open

Enable commonmark alert extension

Added by Marius BĂLTEANU about 1 month ago. Updated 5 days ago.

Status:
Resolved
Priority:
Normal
Category:
Text formatting
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed

Files

0001-Enable-common_mark-alerts.patch (7.46 KB) 0001-Enable-common_mark-alerts.patch Mizuki ISHIKAWA, 2025-04-28 09:45
screenshot 2025-04-28 16.45.56.png (83.4 KB) screenshot 2025-04-28 16.45.56.png Mizuki ISHIKAWA, 2025-04-28 09:46
screenshot 2025-05-07 11.24.20.png (18.6 KB) screenshot 2025-05-07 11.24.20.png Mizuki ISHIKAWA, 2025-05-07 04:25
screenshot 2025-05-07 11.24.03.png (18.6 KB) screenshot 2025-05-07 11.24.03.png Mizuki ISHIKAWA, 2025-05-07 04:25
0001-Add-alerts-help.patch (7.2 KB) 0001-Add-alerts-help.patch Mizuki ISHIKAWA, 2025-05-09 09:46
screenshot 2025-05-09 16.13.25.png (58.7 KB) screenshot 2025-05-09 16.13.25.png Mizuki ISHIKAWA, 2025-05-09 09:48
screenshot 2025-05-09 16.13.03.png (229 KB) screenshot 2025-05-09 16.13.03.png Mizuki ISHIKAWA, 2025-05-09 09:49
0001-Add-alerts-help.patch (6.56 KB) 0001-Add-alerts-help.patch Mizuki ISHIKAWA, 2025-05-09 09:53
clipboard-202505150917-dx53t.png (2.52 KB) clipboard-202505150917-dx53t.png Florian Walchshofer, 2025-05-15 09:17
Actions #1

Updated by Mizuki ISHIKAWA 23 days ago

I am attaching a patch that enables the alerts extension in commonMark.

Input:

> [!TIP]
> Something of tip

> [!note]
> Something of note

> [!warning]
> Something of warning
> |A |B |
> |--|--|
> |  |  |

> [!important]
> Something of warning

> [!caution]
> Something of warning

> [!other]
> This should not become an alert.

It will be displayed as follows by the common_mark gem:

Feedback on the appearance of the alerts, such as their colors, is welcome.

Additional Notes:
  • This patch does not support PDF export functionality.
  • Alert types such as Note and Important are not localized and will always be displayed in English regardless of the user's language.
Actions #2

Updated by Marius BĂLTEANU 21 days ago

  • Category set to Text formatting
  • Status changed from New to Resolved
  • Assignee set to Marius BĂLTEANU
  • Target version changed from Candidate for next major release to 6.1.0
  • Resolution set to Fixed

Thanks for taking care of this!

Mizuki ISHIKAWA wrote in #note-1:

I am attaching a patch that enables the alerts extension in commonMark.

Input:
[...]

It will be displayed as follows by the common_mark gem:
[...]

Feedback on the appearance of the alerts, such as their colors, is welcome.

From my point of view, the colors are ok.

Additional Notes:
  • This patch does not support PDF export functionality.

I think this we should fix it, I will take a look in the following days.

  • Alert types such as Note and Important are not localized and will always be displayed in English regardless of the user's language.

I'm not sure if it's really needed.

Beside these, we need to update the wiki pages help.

Actions #3

Updated by Mizuki ISHIKAWA 20 days ago

When running the following stylelint check:

$ npx stylelint "app/assets/stylesheets/**/*.css" 

app/assets/stylesheets/application.css
  1279:3  ✖  Unexpected shorthand "margin" after "margin-bottom"  declaration-block-no-shorthand-property-overrides

✖ 1 problem (1 error, 0 warnings)

This issue can be fixed with the following diff:

diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css
index c63a89a75..5c6ca8172 100644
--- a/app/assets/stylesheets/application.css
+++ b/app/assets/stylesheets/application.css
@@ -1275,8 +1275,7 @@ div.flash.warning svg.icon-svg, .conflict svg.icon-svg {

 .markdown-alert-title {
   font-weight: bold;
-  margin-bottom: 0.5em;
-  margin: 0;
+  margin: 0 0 0.5em 0;
 }

 .markdown-alert-tip { border-color: #5db651; }

Actions #4

Updated by Go MAEDA 20 days ago

Mizuki ISHIKAWA wrote in #note-3:

When running the following stylelint check:
[...]

This issue can be fixed with the following diff:
[...]

Thank you, I have committed the fix in r23730.

Actions #5

Updated by Mizuki ISHIKAWA 14 days ago

The uneven top and bottom padding of the alert is a bit distracting, so I would like to adjust the spacing to match the quote.

diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css
index 7dc97a8f9..4a352888a 100644
--- a/app/assets/stylesheets/application.css
+++ b/app/assets/stylesheets/application.css
@@ -1263,17 +1263,12 @@ div.flash.warning svg.icon-svg, .conflict svg.icon-svg {
 /***** CommonMark Alerts *****/
 .markdown-alert {
   border-left: 4px solid;
-  padding: 10px 10px 1px 10px;
-  margin: 10px 0;
-}
-
-.markdown-alert-title + p {
-  margin-top: 2px;
+  padding-left: 0.6em;
+  margin: 1em 0;
 }

 .markdown-alert-title {
   font-weight: bold;
-  margin: 0 0 0.5em 0;
 }

 .markdown-alert-tip { border-color: #5db651; }
before change after change
Actions #6

Updated by Mizuki ISHIKAWA 12 days ago

I have attached a patch to add to the help. It is for English only.
I am not a native English speaker, so please correct me if you find anything unnatural!

Actions #7

Updated by Mizuki ISHIKAWA 12 days ago

Patch slightly modified.

Actions #8

Updated by Marius BĂLTEANU 7 days ago

Mizuki ISHIKAWA wrote in #note-6:

I have attached a patch to add to the help. It is for English only.
I am not a native English speaker, so please correct me if you find anything unnatural!

Thanks!

Is there any reason for why you chose to write [!NOTE], [!TIP], [!IMPORTANT], [!WARNING], and [!CAUTION] with capital letters?

Actions #9

Updated by Mizuki ISHIKAWA 6 days ago

Marius BĂLTEANU wrote in #note-8:

Mizuki ISHIKAWA wrote in #note-6:

I have attached a patch to add to the help. It is for English only.
I am not a native English speaker, so please correct me if you find anything unnatural!

Thanks!

Is there any reason for why you chose to write [!NOTE], [!TIP], [!IMPORTANT], [!WARNING], and [!CAUTION] with capital letters?

https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts
I chose to use capital letters for [!NOTE], [!TIP], [!IMPORTANT], [!WARNING], and [!CAUTION] because they were also capitalized on the GitHub syntax page. However, replacing them with lowercase is perfectly fine if you prefer.

Actions #10

Updated by Marius BĂLTEANU 6 days ago

Mizuki ISHIKAWA wrote in #note-9:

[...]

Is there any reason for why you chose to write [!NOTE], [!TIP], [!IMPORTANT], [!WARNING], and [!CAUTION] with capital letters?

https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts
I chose to use capital letters for [!NOTE], [!TIP], [!IMPORTANT], [!WARNING], and [!CAUTION] because they were also capitalized on the GitHub syntax page. However, replacing them with lowercase is perfectly fine if you prefer.

Got it, thanks!

Actions #12

Updated by Marius BĂLTEANU 5 days ago

Florian Walchshofer wrote in #note-11:

I would also prefer if this initial symbol is also displayed, just like on the GitHub syntax page
https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts

Yes, I think we can have a HTML::Pipeline::Filter that adds the properly svg icon. The following code is just an example to prove the implementation, it still need some work to be finalised.

include IconsHelper

module Redmine
  module WikiFormatting
    module CommonMark
      class AlertsIconsFilter < HTML::Pipeline::Filter
        def call
          doc.search("p.markdown-alert-title").each do |node|
            alert_class = node.parent['class']
            alert_class.slice!("markdown-alert ")

            #ToDo: Extend notice_icon to support all alert types or add a new method
            icon = notice_icon('notice')
            node.prepend_child(icon)
          end
          doc
        end
      end
    end
  end
end
Actions

Also available in: Atom PDF