Improve ASAL export functions

This commit is contained in:
mez 2024-06-04 20:57:50 +01:00
parent 3ae8ba63cb
commit 4847fbf799
2 changed files with 45 additions and 15 deletions

View file

@ -134,10 +134,24 @@
(setq texfile (concat (file-name-base) ".tex"))
(find-file-noselect texfile)
(with-current-buffer texfile
(shell-command
(format "pandoc %s -o %s.epub"
(shell-quote-argument (buffer-file-name))
(shell-quote-argument (file-name-base))))
(if asal
(progn
(goto-char (point-min))
(search-forward "\\begin{document}")
(while (re-search-forward "\n" nil t)
(replace-match "\n\n"))
(save-buffer)
(shell-command
(format "pandoc %s -o %s.epub --epub-cover-image=/home/mdd/Documents/drive/the\\ walk/cover.png"
(shell-quote-argument (buffer-file-name))
(shell-quote-argument (file-name-base)))))
(shell-command
(format "pandoc %s -o %s.epub"
(shell-quote-argument (buffer-file-name))
(shell-quote-argument (file-name-base)))))
(goto-char (point-min))
(while (re-search-forward "label{\\(.*\\)}\n\n" nil t)
(replace-match "label{\\1}\n"))
(goto-char (point-min))
(while (re-search-forward "label{\\(.*\\)}\n\\([A-Z]\\)\\([a-z]*\\)" nil t)
(replace-match "label{\\1}\n\\\\lettrine{\\2}{\\3}"))
@ -228,26 +242,26 @@
(goto-char (point-max))
(save-buffer)
;; (unless draftmode
(shell-command
(format "xelatex -interaction=batchmode %s"
(shell-quote-argument (buffer-file-name))))
(shell-command
(format "xelatex -interaction=batchmode %s"
(shell-quote-argument (buffer-file-name))))
(shell-command
(format "xelatex -interaction=batchmode %s"
(shell-quote-argument (buffer-file-name))))
(shell-command
(format "xelatex -interaction=batchmode %s"
(shell-quote-argument (buffer-file-name))))
;; )
(kill-current-buffer))
;; (unless draftmode
(delete-file "FFXYevon.ttf")
(if (file-exists-p (concat (file-name-base) ".aux"))
(delete-file (concat (file-name-base) ".aux")))
(delete-file (concat (file-name-base) ".aux")))
(if (file-exists-p (concat (file-name-base) ".log"))
(delete-file (concat (file-name-base) ".log")))
(delete-file (concat (file-name-base) ".log")))
(if (file-exists-p (concat (file-name-base) ".out"))
(delete-file (concat (file-name-base) ".out")))
(delete-file (concat (file-name-base) ".out")))
(if (file-exists-p (concat (file-name-base) ".toc"))
(delete-file (concat (file-name-base) ".toc")))
(delete-file (concat (file-name-base) ".toc")))
(if (file-exists-p "texput.log")
(delete-file "texput.log"))
(delete-file "texput.log"))
(delete-file texfile)
;; )
(message "Done")))