From 0fafc2a01ec5948a1b79a969c6374c7f1566c43e Mon Sep 17 00:00:00 2001 From: Kaushal Modi Date: Tue, 21 Jan 2020 15:16:29 -0500 Subject: [PATCH] Unwrap Japanese characters without inserting space as well Ref: https://github.com/kaushalmodi/ox-hugo/issues/320 --- doc/ox-hugo-manual.org | 14 ++++++++------ ox-hugo.el | 15 +++++++++------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/doc/ox-hugo-manual.org b/doc/ox-hugo-manual.org index 1a68a9b..4879e59 100644 --- a/doc/ox-hugo-manual.org +++ b/doc/ox-hugo-manual.org @@ -2846,9 +2846,10 @@ Here's an example of inlining an SVG: #+caption: An SVG with hyperlink #+attr_html: :inlined t [[file:../test/site/content-org/images/svg-with-hyperlinks.svg]] -*** Chinese Support +*** CJK Support :PROPERTIES: -:EXPORT_FILE_NAME: chinese-support +:EXPORT_FILE_NAME: cjk-support +:EXPORT_HUGO_ALIASES: chinese-support japanese-support :END: **** Auto-unwrapping of lines with multi-byte characters This issue came up on this [[https://emacs-china.org/t/ox-hugo-auto-fill-mode-markdown/9547][emacs-china thread]] .. the issue was that @@ -2865,10 +2866,11 @@ other languages with multi-byte characters (few examples: Hindi, Gujarati). So that line-unwrapping _with space removal_ is done *only if*, -1. The /locale/ is [[https://www.gnu.org/software/gettext/manual/html_node/Locale-Environment-Variables.html][auto-detected]] to be Chinese via environment - variables /LANGUAGE/, /LC_ALL/ or /LANG/, or -2. The /locale/ is *manually set* to Chinese by setting it to *zh* - using ~#+hugo_locale:~ keyword (or ~EXPORT_HUGO_LOCALE~ property). +1. The /locale/ is [[https://www.gnu.org/software/gettext/manual/html_node/Locale-Environment-Variables.html][auto-detected]] to be Chinese or Japanese via + environment variables /LANGUAGE/, /LC_ALL/ or /LANG/, or +2. The /locale/ is *manually set* to Chinese or Japanese by setting it + to *zh* or *ja* using ~#+hugo_locale:~ keyword (or + ~EXPORT_HUGO_LOCALE~ property). *** COMMENT Hugo Bundle :PROPERTIES: :EXPORT_FILE_NAME: hugo-bundle diff --git a/ox-hugo.el b/ox-hugo.el index b0f0322..9f76a54 100644 --- a/ox-hugo.el +++ b/ox-hugo.el @@ -1,6 +1,6 @@ ;;; ox-hugo.el --- Hugo Markdown Back-End for Org Export Engine -*- lexical-binding: t -*- -;; Authors: Kaushal Modi +;; Authors: Kaushal Modi ;; Matt Price ;; URL: https://ox-hugo.scripter.co ;; Package-Requires: ((emacs "24.4") (org "9.0")) @@ -2466,11 +2466,14 @@ communication channel." ;; (message "[org-hugo-paragraph DBG] para 1: %s" contents) - ;; Join consecutive Chinese lines into a single long line without - ;; unwanted space inbetween. - (let ((lang (org-hugo--get-lang info))) - (when (and lang - (string-prefix-p "zh" lang)) ;"zh", "zh_CH", .. + ;; Join consecutive Chinese, Japanese lines into a single long + ;; line without unwanted space inbetween. + (let* ((lang (org-hugo--get-lang info)) + (lang-2chars (when (and (stringp lang) + (>= (length lang) 2)) + (substring lang 0 2)))) + (when (and lang-2chars + (member lang-2chars '("zh" "ja"))) ;"zh", "zh_CH", "ja", .. ;; https://emacs-china.org/t/ox-hugo-auto-fill-mode-markdown/9547/5 ;; Example: 这是一个测试 -> 这是一个测试文本 ("This is a test text") ;; 文本