Skip to content

Commit

Permalink
Do not insert spaces when unwrapping footnote text for CJK langs
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushalmodi committed Jan 21, 2020
1 parent c60a839 commit 4d3890d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
14 changes: 11 additions & 3 deletions ox-blackfriday.el
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,12 @@ INFO is a plist used as a communication channel."
(concat indent "- [" title "]" "(#" anchor ")")))

;;;; Footnote section
(defun org-blackfriday-footnote-section (info)
(defun org-blackfriday-footnote-section (info &optional is-cjk)
"Format the footnote section.
INFO is a plist used as a communication channel."
INFO is a plist used as a communication channel.
IS-CJK should be set to non-nil if the language is Chinese,
Japanese or Korean."
(let ((fn-alist (org-export-collect-footnote-definitions info))
;; Fri Jul 21 14:33:25 EDT 2017 - kmodi
;; TODO: Need to learn using cl-loop
Expand All @@ -142,7 +145,12 @@ INFO is a plist used as a communication channel."
;; Support multi-line footnote definitions by folding all
;; footnote definition lines into a single line as Blackfriday
;; does not support that.
(setq def (replace-regexp-in-string "\n" " " def))
(setq def (replace-regexp-in-string
"\n"
;; Do not insert spaces when joining newlines for
;; CJK languages.
(if is-cjk "" " ")
def))
;; Replace multiple consecutive spaces with a single space.
(setq def (replace-regexp-in-string "[[:blank:]]+" " " def))
(push (cons n def) fn-alist-stripped)
Expand Down
2 changes: 1 addition & 1 deletion ox-hugo.el
Original file line number Diff line number Diff line change
Expand Up @@ -1975,7 +1975,7 @@ holding export options."
;; Make sure CONTENTS is separated from table of contents
;; and footnotes with at least a blank line.
"\n"
(org-blackfriday-footnote-section info)))))
(org-blackfriday-footnote-section info (org-hugo--lang-cjk-p info))))))

;;;; Keyword
(defun org-hugo-keyword (keyword contents info)
Expand Down
9 changes: 9 additions & 0 deletions test/site/content-org/all-posts.org
Original file line number Diff line number Diff line change
Expand Up @@ -2600,6 +2600,12 @@ This is some text[fn:1].
:EXPORT_FILE_NAME: multi-line-footnote
:END:
This is some text[fn:3].
** Multi-line footnote Japanese
:PROPERTIES:
:EXPORT_FILE_NAME: multi-line-footnote-japanese
:EXPORT_HUGO_LOCALE: ja
:END:
This is some text[fn:6].
** Bind footnotes to the preceding word
:PROPERTIES:
:EXPORT_FILE_NAME: footnotes-bind-to-preceding-word
Expand Down Expand Up @@ -7528,6 +7534,9 @@ Results from static site search implemented using /Fusejs/, /jquery/
and /mark.js/. -- [[https://gist.github.com/eddiewebb/735feb48f50f0ddd65ae5606a1cb41ae][Source]]
* Footnotes

[fn:6] これは
テストです.

[fn:5] See [@thompson2016].
[fn:4] Even if the user has set the =HUGO_CODE_FENCE= value to =t=
(via variable, keyword or subtree property), the Hugo =highlight=
Expand Down
9 changes: 9 additions & 0 deletions test/site/content/posts/multi-line-footnote-japanese.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
+++
title = "Multi-line footnote Japanese"
tags = ["footnote"]
draft = false
+++

This is some text[^fn:1].

[^fn:1]: これはテストです.

0 comments on commit 4d3890d

Please sign in to comment.