jrblevin / markdown-mode

Emacs Markdown Mode
http://jblevins.org/projects/markdown-mode/
GNU General Public License v3.0
877 stars 160 forks source link

Consider character width to display horizontal rule in markdown-view-mode #755

Closed syohex closed 1 year ago

syohex commented 1 year ago

Description

The width of separator character which is used to display horizontal rule is 2 in CJK language settings(Chinese, Korean, Japanese etc), so markdown-mode should consider its character width.

(set-language-environment "Japanese")
(char-width #x2500) ;; => 2

(set-language-environment "English")
(char-width #x2500) ;; => 1

Original version

image

This PR version

image

Note

image

CJK users should set terminal configuration of ambiguous character width correctly. For example Gnome Terminal, set Ambiguous-Width Characters to Wide. If not, it looks like as below, the separator line is too short. Because char-width returns 2(full-width) but display width is 1(half-width).

image

If your terminal does not support CJK ambiguous characters, then you should remove such characters from markdown-hr-display-char like

(setq markdown-hr-display-char '(?-))

Related Issue

753

Type of Change

Checklist

This is difficult to test