Project

General

Profile

Actions

Patch #40939

closed

Add "underline" button to jsToolbar for CommonMark Markdown formatting

Added by Yasu Saku 5 months ago. Updated 29 days ago.

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

0%

Estimated time:

Description

The Textile and Markdown text formatting have an "underline" button in the jsToolbar.
However, the CommonMark Markdown text format does not.

Also, CommonMark Markdown supports HTML tags.
So I created a patch to insert `<ins></ins>` tags.


Files


Related issues

Blocks Redmine - Feature #40149: Drop deprecated Redcarpet based Markdown formatterClosedGo MAEDA

Actions
Actions #1

Updated by Go MAEDA 5 months ago

Thank you for the proposal to add an "Underline" button to the CommonMark Markdown toolbar.

However, I think it is better to use <u> instead of <ins>, as in Redcarpet-based Markdown. This is because <ins> is semantically intended to represent inserted text, so using <ins> only to express underline is not semantically appropriate.

I have updated the patch to use the <u> element accordingly.

Actions #2

Updated by Yasu Saku 5 months ago

Go MAEDA wrote in #note-1:

Thank you for the proposal to add an "Underline" button to the CommonMark Markdown toolbar.

However, I think it is better to use <u> instead of <ins>, as in Redcarpet-based Markdown. This is because <ins> is semantically intended to represent inserted text, so using <ins> only to express underline is not semantically appropriate.

I have updated the patch to use the <u> element accordingly.

Thank you for the correction and explanation.
But, I am a little concerned about the `ins` in the comments, including other text formatting. Why?

Actions #3

Updated by Go MAEDA 4 months ago

I investigated why the comment // ins is used for the "Underline" button in markdown.js.

First, in Textile, which was the only available formatter before Redcarpet-based Markdown was implemented in Redmine 2.5.0, the <ins> tag is used to represent underlined text. Therefore, it makes sense for the comment // ins to be used for the "Underline" button in textile.js (source:trunk/app/assets/javascripts/jstoolbar/textile.js@22937#L29).

However, in Markdown based on Redcarpet, the <u> tag is used for underlined text. Despite this, the comment in markdown.js still says // ins (source:trunk/app/assets/javascripts/jstoolbar/markdown.js@22937#L29). It would be more appropriate for it to say // u. It is likely that when the underline button was added to the Markdown toolbar in r17385, the comment // ins from textile.js was copied over without being changed.

Therefore, I suggest proceeding as follows:

  • For the CommonMark Markdown toolbar, follow the implementation of Redcarpet-based Markdown and use the <u> tag to represent underlined text, as I proposed in 40939-v2.patch.
  • Change the comment // ins in 40939-v2.patch to // u.
  • Change the existing comments in markdown.js to // u to match the HTML output by Redcarpet.
Actions #4

Updated by Go MAEDA 4 months ago

Following the proposal made in #note-3, I have updated the patches.

1. The first patch corrects the comment in the Redcarpet-based Markdown underline button code to // u. This is because the final output HTML uses the `<u>` tag to achieve the underline effect.
2. The second patch adds an underline button to the CommonMark Markdown toolbar. This is a slightly modified version of the patch provided by Yasu Saku.

Actions #5

Updated by Go MAEDA 4 months ago

  • Target version set to 6.0.0

Setting the target version to 6.0.0.

Actions #6

Updated by Yasu Saku 4 months ago

Thank you Mr. Go MAEDA.

I have understood the historical context in which the //ins comment was added.
In addition, I think it would be better to change jsToolBar.prototype.elements.ins to jsToolBar.prototype.elements.u.
What do you think?

diff --git a/app/assets/javascripts/jstoolbar/common_mark.js b/app/assets/javascripts/jstoolbar/common_mark.js
index f9e5ba7..5c3627a 100644
--- a/app/assets/javascripts/jstoolbar/common_mark.js
+++ b/app/assets/javascripts/jstoolbar/common_mark.js
@@ -26,6 +26,16 @@ jsToolBar.prototype.elements.em = {
   }
 }

+// u
+jsToolBar.prototype.elements.u = {
+  type: 'button',
+  title: 'Underline',
+  shortcut: 'u',
+  fn: {
+    wiki: function() { this.singleTag('<u>', '</u>') }
+  }
+}
+
 // del
 jsToolBar.prototype.elements.del = {
   type: 'button',
diff --git a/app/assets/stylesheets/jstoolbar.css b/app/assets/stylesheets/jstoolbar.css
index 6870261..38c70c1 100644
--- a/app/assets/stylesheets/jstoolbar.css
+++ b/app/assets/stylesheets/jstoolbar.css
@@ -113,6 +113,9 @@
 .jstb_ins {
     background-image: url(/jstoolbar/bt_ins.png);
 }
+.jstb_u {
+    background-image: url(/jstoolbar/bt_ins.png);
+}
 .jstb_del {
     background-image: url(/jstoolbar/bt_del.png);
 }
Actions #7

Updated by Go MAEDA about 1 month ago

Yasu Saku wrote in #note-6:

In addition, I think it would be better to change jsToolBar.prototype.elements.ins to jsToolBar.prototype.elements.u.

To make that change, probably we need to change textile.js as well as jstoolbar.css. I am not willing to change so many files for a simple change of adding a single button to the CommonMark Markdown toolbar.

Actions #8

Updated by Yasu Saku about 1 month ago

Go MAEDA wrote in #note-7:

To make that change, probably we need to change textile.js as well as jstoolbar.css. I am not willing to change so many files for a simple change of adding a single button to the CommonMark Markdown toolbar.

Thank you for your opinion. Understood. I appreciate your assistance.

Actions #9

Updated by Go MAEDA about 1 month ago

  • Blocks Feature #40149: Drop deprecated Redcarpet based Markdown formatter added
Actions #10

Updated by Go MAEDA about 1 month ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA

Committed the patch in r23106.

The CommonMark toolbar now includes an underline button, the same as the toolbars for Textile and Redcarpet-based Markdown.

Actions #11

Updated by Mizuki ISHIKAWA 29 days ago

The InlineAutocompleteSystemTest#test_keyboard_shortcuts_for_wiki_toolbar_buttons_using_markdown test is failing because the system test expectation has not been changed.
I would like to see the expected value changed to “<u></u>” as follows.

diff --git a/test/system/keyboard_shortcuts_test.rb b/test/system/keyboard_shortcuts_test.rb
index 32f5dbe56..361326be1 100644
--- a/test/system/keyboard_shortcuts_test.rb
+++ b/test/system/keyboard_shortcuts_test.rb
@@ -100,7 +100,7 @@ class InlineAutocompleteSystemTest < ApplicationSystemTestCase
       # Clear textarea value
       fill_in 'Description', :with => ''
       find('#issue_description').send_keys([modifier_key, 'u'])
-      assert_equal '__', find('#issue_description').value
+      assert_equal '<u></u>', find('#issue_description').value

       # Clear textarea value
       fill_in 'Description', :with => ''

Actions #12

Updated by Go MAEDA 29 days ago

Mizuki ISHIKAWA wrote in #note-11:

The InlineAutocompleteSystemTest#test_keyboard_shortcuts_for_wiki_toolbar_buttons_using_markdown test is failing because the system test expectation has not been changed.
I would like to see the expected value changed to “<u></u>” as follows.

[...]

Committed the fix in r23160. Thank you for catching and fixing the test failure.

Actions

Also available in: Atom PDF