Skip to content

Commit

Permalink
Improve the footnote wrapping when a zh/ja lang post has English too
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushalmodi committed Jan 22, 2020
1 parent 4d3890d commit 1dbf3cf
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
14 changes: 8 additions & 6 deletions ox-blackfriday.el
Expand Up @@ -145,12 +145,14 @@ Japanese or Korean."
;; 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"
;; Do not insert spaces when joining newlines for
;; CJK languages.
(if is-cjk "" " ")
def))
(setq def (if is-cjk
(replace-regexp-in-string
;; Do not insert spaces when joining newlines for
;; CJK languages.
"\\([[:multibyte:]]\\)[[:blank:]]*\n[[:blank:]]*\\([[:multibyte:]]\\)" "\\1\\2"
def)
(replace-regexp-in-string "\n" " " 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
12 changes: 11 additions & 1 deletion test/site/content-org/all-posts.org
Expand Up @@ -2605,7 +2605,13 @@ This is some text[fn:3].
:EXPORT_FILE_NAME: multi-line-footnote-japanese
:EXPORT_HUGO_LOCALE: ja
:END:
This is some text[fn:6].
Here is a footnote where it originally had Japanese text on both
lines[fn:6].

Here is a footnote where originally the first line ended in English
but next line started with Japanese[fn:7].

Here is a footnote entirely in English[fn:3].
** Bind footnotes to the preceding word
:PROPERTIES:
:EXPORT_FILE_NAME: footnotes-bind-to-preceding-word
Expand Down Expand Up @@ -7534,10 +7540,14 @@ Results from static site search implemented using /Fusejs/, /jquery/
and /mark.js/. -- [[https://gist.github.com/eddiewebb/735feb48f50f0ddd65ae5606a1cb41ae][Source]]
* Footnotes

[fn:7] English on line 1
の Japanese on line 2

[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=
shortcode will be used automatically instead of code fences if either
Expand Down
10 changes: 9 additions & 1 deletion test/site/content/posts/multi-line-footnote-japanese.md
Expand Up @@ -4,6 +4,14 @@ tags = ["footnote"]
draft = false
+++

This is some text[^fn:1].
Here is a footnote where it originally had Japanese text on both
lines[^fn:1].

Here is a footnote where originally the first line ended in English
but next line started with Japanese[^fn:2].

Here is a footnote entirely in English[^fn:3].

[^fn:1]: これはテストです.
[^fn:2]: English on line 1 の Japanese on line 2
[^fn:3]: This is a long footnote. It is so long that it gets auto-filled over multiple lines. But even then it should be handled fine.

0 comments on commit 1dbf3cf

Please sign in to comment.