diff options
| author | JSDurand <mmemmew@gmail.com> | 2026-05-06 02:15:04 +0800 |
|---|---|---|
| committer | JSDurand <mmemmew@gmail.com> | 2026-05-06 02:15:04 +0800 |
| commit | c5ec16b6ef88248213ce1438ac78ffea28b90a9e (patch) | |
| tree | c13904cc4a53d2762d748935b4811d91c26e8494 | |
| parent | 6518254d34490bc229f72c6152b3683e534d76cc (diff) | |
* org-conf.el ("account.el"): Now I do not always load this account
package, as I have stopped logging my expenses now, thinking that
this is not of too much help to me.
(durand-org-quote-export-filter,
org-export-filter-quote-block-functions): This recognizes a specific
heading of '-#-' as starting the author of the quote. This author
part will be put in the cite element in html output. The associated
CSS file can then treat this element in a specific manner to make
the author stand out.
(durand-org-no-chinese-spaces,
org-export-filter-paragraph-functions): This removes extra spaces
added by the line breaks within a paragraph. This space is normal
to English paragraphs, but is quite uncomfortable to reading Chinese
articles. Fortunately I finally found a solutation to this problem
by removing the line break if it is found between two Chinese
characters. Actually more than Chinese characters are recognized
here, such as Korean and Japanese characters are considered as well.
The reason to consider them is simple: it is a matter of adding more
categories to the matching regular expression, so why not add it.
After all, I might decide to learn Korean and Japanese seriously in
the future, who knows. :P
| -rw-r--r-- | org-conf.el | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/org-conf.el b/org-conf.el index 6287658..95b4150 100644 --- a/org-conf.el +++ b/org-conf.el @@ -381,7 +381,7 @@ in Lisp code use `org-set-tags' instead." ;;; Accounts -(load-file "account.el") +;; (load-file "account.el") ;; ;;;###autoload ;; (defvar durand-org-capture-account-which-list @@ -1163,6 +1163,67 @@ title." (advice-add #'org-html-publish-to-html :filter-return #'durand-org-publish-html-advice) +;;;; Author element in quotes + +;; I want to note the author in quotes, and have the authors stand out +;; a little. + +(defun durand-org-quote-export-filter (text backend _info) + "Turn ending lines beginning with two dashes into footer elements. +The parameters TEXT, BACKEND, and INFO are subject to the rules of +`org-export-filter-quote-block-functions'." + (cond + ((org-export-derived-backend-p backend 'html) + (message "text: %s" text) + (replace-regexp-in-string + (rx-to-string + (list 'seq 'bol "-#- " + (list 'group-n 1 (list 'one-or-more 'anychar)) + "</p>") + t) + "<footer><cite>\\1</cite></footer>" + text)))) + +(add-to-list 'org-export-filter-quote-block-functions + #'durand-org-quote-export-filter) + +;;;; Remove spaces between Chinese characters + +(defun durand-org-no-chinese-spaces (text backend _info) + "Remove extra spaces caused by line breaks between Chinese +characters. + +The parameters TEXT, BACKEND, and INFO are subject to the rules of +`org-export-filter-quote-block-functions'." + (cond + ((org-export-derived-backend-p backend 'html) + (let ((regex (rx-to-string + (list + 'seq + (list + 'or + (list 'category 'korean-hangul-two-byte) + (list 'category 'chinese) + (list 'category 'korean) + (list 'category 'japanese) + (list 'category 'japanese-katakana))) + t))) + (setq text (replace-regexp-in-string + (format "\\(%s\\) *\n *\\(%s\\)" regex regex) + "\\1\\2" text)) + ;; Handle extra spaces at boundaries between Chinese and + ;; non-Chinese. + (setq text (replace-regexp-in-string + (format "\\(%s\\) *\n" regex) + "\\1" text)) + (setq text (replace-regexp-in-string + (format "\n *\\(%s\\)" regex) + "\\1" text)))) + text)) + +(add-to-list 'org-export-filter-paragraph-functions + #'durand-org-no-chinese-spaces) + ;;;; Atom feed ;;;;; Fixed pre-amble, template, and post-amble. |
