Project

General

Profile

Actions

Feature #43234

open

Enable CJK-friendly emphasis extension for CommonMark

Added by Katsuya HIDAKA 3 days ago. Updated about 15 hours ago.

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

0%

Estimated time:
Resolution:
Fixed

Description

This patch enables the CJK-friendly emphasis extension in commonmarker to properly parse Markdown emphasis (**) with CJK (Chinese, Japanese, Korean) characters. This resolves a known issue where emphasis marks were not correctly interpreted when adjacent to CJK characters, such as in **テスト。**テスト.

Input:

Before:

After:

I believe this will help improve the user experience for CJK language users.

According to the documentation for the package that this extension is based on, enabling it does not affect languages other than CJK.

This modification of the specification does not affect the other languages than Chinese, Japanese, and Korean. Even if your application or document has translations or content in other languages, it will not be affected

I have also verified its functionality with English, Spanish, and French, and found no issues. All tests have passed with this patch.
https://github.com/hidakatsuya/redmine/actions/runs/17896214845

diff --git a/Gemfile b/Gemfile
index 9cde32ec8..add1363f7 100644
--- a/Gemfile
+++ b/Gemfile
@@ -18,7 +18,7 @@ gem 'propshaft', '~> 1.1.0'
 gem 'rack', '>= 3.1.3'
 gem "stimulus-rails", "~> 1.3" 
 gem "importmap-rails", "~> 2.0" 
-gem 'commonmarker', '~> 2.3.0'
+gem 'commonmarker', '~> 2.3.2'
 gem "doorkeeper", "~> 5.8.2" 
 gem "bcrypt", require: false
 gem "doorkeeper-i18n", "~> 5.2" 
diff --git a/lib/redmine/wiki_formatting/common_mark/formatter.rb b/lib/redmine/wiki_formatting/common_mark/formatter.rb
index 8b7a18394..2b5f3f163 100644
--- a/lib/redmine/wiki_formatting/common_mark/formatter.rb
+++ b/lib/redmine/wiki_formatting/common_mark/formatter.rb
@@ -35,6 +35,7 @@ module Redmine
           tasklist: true,
           shortcodes: false,
           alerts: true,
+          cjk_friendly_emphasis: true,
         }.freeze,

         # https://github.com/gjtorikian/commonmarker#parse-options

Files

after.png (33.3 KB) after.png Katsuya HIDAKA, 2025-09-22 13:55
input.png (40.4 KB) input.png Katsuya HIDAKA, 2025-09-22 13:55
before.png (34.4 KB) before.png Katsuya HIDAKA, 2025-09-22 13:55
0001-Enable-CJK-friendly-emphasis-extension-for-CommonMark.patch (1.28 KB) 0001-Enable-CJK-friendly-emphasis-extension-for-CommonMark.patch Katsuya HIDAKA, 2025-09-22 13:55
0002-Add-test-for-enabling-CJK-friendly-emphasis-extension.patch (1.27 KB) 0002-Add-test-for-enabling-CJK-friendly-emphasis-extension.patch Katsuya HIDAKA, 2025-09-23 19:53
Actions #1

Updated by Marius BĂLTEANU 3 days ago

Thanks! Can you add a test, please?

Actions #2

Updated by Marius BĂLTEANU 3 days ago

  • Target version set to Candidate for next minor release
Actions #3

Updated by Katsuya HIDAKA 3 days ago

Sure, I missed adding a test. I'll add it.

Actions #4

Updated by Katsuya HIDAKA 2 days ago

I'm attaching patch 0002, which adds a test to confirm that the CJK-friendly emphasis extension is enabled. Please consider fixuping this patch into patch 0001 when committing.

All tests have been confirmed to pass:
https://github.com/hidakatsuya/redmine/actions/runs/17953931078

Actions #5

Updated by Marius BĂLTEANU 1 day ago

  • Target version changed from Candidate for next minor release to 6.1.1
Actions #6

Updated by Marius BĂLTEANU 1 day ago

  • Assignee set to Marius BĂLTEANU
Actions #7

Updated by Marius BĂLTEANU about 15 hours ago

  • Status changed from New to Resolved
  • Resolution set to Fixed
Actions

Also available in: Atom PDF