From a63688487972259a6b22b6cf8363be0332556827 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tr=C3=A9meur?= Date: Sun, 29 Jan 2023 17:00:15 +0000 Subject: [PATCH] Process fic footnotes properly --- custom/fic.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/custom/fic.el b/custom/fic.el index 58fb56e..b7bd943 100644 --- a/custom/fic.el +++ b/custom/fic.el @@ -1,6 +1,10 @@ (defun fic-ao3 () (interactive) (org-format) + (save-buffer) + (goto-char (point-min)) + (while (re-search-forward "\\[fn:.*\\]" nil t) + (replace-match "")) (let ((org-export-with-title 'nil) (org-export-with-author 'nil) (org-export-with-creator 'nil) @@ -10,6 +14,7 @@ (org-export-with-toc 'nil) (org-html-validation-link 'nil)) (org-html-export-to-html)) + (revert-buffer t t) (setq oldname (concat (file-name-base) ".org")) (setq newname (concat (file-name-base) ".html")) (find-file-noselect newname) @@ -27,6 +32,9 @@ (while (re-search-forward "" nil t) (replace-match "")) (goto-char (point-min)) + (while (re-search-forward "" nil t) + (replace-match "")) + (goto-char (point-min)) (while (re-search-forward "\n\n" nil t) (replace-match "\n")) (write-file newname) @@ -52,6 +60,7 @@ (setq chaptertitles (y-or-n-p "Titled chapters?"))) (setq ffx (y-or-n-p "FFX fic?")))) (org-format) + (save-buffer) (goto-char (point-min)) (while (re-search-forward "\\[fn:\\([0-9]*\\):\\(.*\\)\\]" nil t) (replace-match "@@html:\\2@@@@latex:\\\\footnote{\\2}@@")) @@ -59,7 +68,7 @@ (org-html-head "")) (org-html-export-to-html) (org-latex-export-to-latex)) - (save-buffer) + (revert-buffer t t) (setq htmlfile (concat (file-name-base) ".html")) (find-file-noselect htmlfile) (with-current-buffer htmlfile