Project

General

Profile

Actions

Feature #43234

open

Enable CJK-friendly emphasis extension for CommonMark

Added by Katsuya HIDAKA about 10 hours ago. Updated about 4 hours ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Text formatting
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:

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
Actions #1

Updated by Marius BĂLTEANU about 6 hours ago

Thanks! Can you add a test, please?

Actions #2

Updated by Marius BĂLTEANU about 6 hours ago

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

Updated by Katsuya HIDAKA about 4 hours ago

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

Actions

Also available in: Atom PDF