Huang Jing <[email protected]> writes: >> I've been looking through our radio target parser and noted that it has >> special arragenemnt for Chinese by allowing the boundary to be a regexp >> \c| (line-breakable character). AFAIU, this should include Chinese and >> Japanese glyphs. > > Then if I understand correctly, it should handle CJK chars with inline > markups correct? > > I'll ask in the forum if it's the case.
I think so. See the attached.
>From b1f0efc51add10852d34738bc0a3142c1970d6d6 Mon Sep 17 00:00:00 2001 Message-ID: <b1f0efc51add10852d34738bc0a3142c1970d6d6.1765866137.git.yanta...@posteo.net> From: Ihor Radchenko <[email protected]> Date: Tue, 16 Dec 2025 07:21:44 +0100 Subject: [PATCH] DRAFT: Allow all characters that can break as emphasis boundaries --- lisp/org-element.el | 4 +++- lisp/org.el | 29 +++++++++++++++-------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index 6abccd001..155ff09bd 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -3331,7 +3331,8 @@ (defun org-element--parse-generic-emphasis (mark type) (unless (bolp) (forward-char -1)) (let ((opening-re (rx-to-string - `(seq (or line-start (any space ?- ?\( ?' ?\" ?\{)) + `(seq (or line-start (any space ?- ?\( ?' ?\" ?\{) + (category can-break)) ,mark (not space))))) (when (looking-at-p opening-re) @@ -3342,6 +3343,7 @@ (defun org-element--parse-generic-emphasis (mark type) (not space) (group ,mark) (or (any space ?- ?. ?, ?\; ?: ?! ?? ?' ?\" ?\) ?\} ?\\ ?\[) + (category can-break) line-end))))) (when (re-search-forward closing-re nil t) (let ((closing (match-end 1))) diff --git a/lisp/org.el b/lisp/org.el index 67d9679fe..5f47dab93 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -3850,10 +3850,11 @@ (defun org-set-emph-re (var val) (body (if (<= nl 0) body (format "%s*?\\(?:\n%s*?\\)\\{0,%d\\}" body body nl))) (template - (format (concat "\\([%s]\\|^\\)" ;before markers - "\\(\\([%%s]\\)\\([^%s]\\|[^%s]%s[^%s]\\)\\3\\)" - "\\([%s]\\|$\\)") ;after markers - pre border border body border post))) + (let ((pre "\\c|") (post "\\c|")) + (format (concat "\\(%s\\|^\\)" ;before markers + "\\(\\([%%s]\\)\\([^%s]\\|[^%s]%s[^%s]\\)\\3\\)" + "\\(%s\\|$\\)") ;after markers + pre border border body border post)))) (setq org-emph-re (format template "*/_+")) (setq org-verbatim-re (format template "=~"))))) @@ -5385,8 +5386,8 @@ (defsubst org-rear-nonsticky-at (pos) (defun org-do-emphasis-faces (limit) "Run through the buffer and emphasize strings." - (let ((quick-re (format "\\([%s]\\|^\\)\\([~=*/_+]\\)" - (car org-emphasis-regexp-components)))) + (let ((quick-re (rx (group (or bol (category can-break))) + (group (any ?~ ?= ?* ?/ ?_ ?+))))) (catch :exit (while (re-search-forward quick-re limit t) (let* ((marker (match-string 2)) @@ -5396,24 +5397,24 @@ (defun org-do-emphasis-faces (limit) (and ;; Do not match table hlines. (not (and (equal marker "+") - (org-match-line - "[ \t]*\\(|[-+]+|?\\|\\+[-+]+\\+\\)[ \t]*$"))) + (org-match-line + "[ \t]*\\(|[-+]+|?\\|\\+[-+]+\\+\\)[ \t]*$"))) ;; Do not match headline stars. Do not consider ;; stars of a headline as closing marker for bold ;; markup either. (not (and (equal marker "*") - (save-excursion - (forward-char) - (skip-chars-backward "*") - (looking-at-p org-outline-regexp-bol)))) + (save-excursion + (forward-char) + (skip-chars-backward "*") + (looking-at-p org-outline-regexp-bol)))) ;; Match full emphasis markup regexp. (looking-at (if verbatim? org-verbatim-re org-emph-re)) ;; Do not span over paragraph boundaries. (not (string-match-p org-element-paragraph-separate - (match-string 2))) + (match-string 2))) ;; Do not span over cells in table rows. (not (and (save-match-data (org-match-line "[ \t]*|")) - (string-match-p "|" (match-string 4)))))) + (string-match-p "|" (match-string 4)))))) (pcase-let ((`(,_ ,face ,_) (assoc marker org-emphasis-alist)) (m (if org-hide-emphasis-markers 4 2))) (font-lock-prepend-text-property -- 2.50.1
-- Ihor Radchenko // yantar92, Org mode maintainer, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>
