diff --git a/README.org b/README.org index 2942c55..f3b038b 100644 --- a/README.org +++ b/README.org @@ -73,9 +73,14 @@ and /TSV/ files use ~sed~ (only really affects Windows users). + Rmarkdown :: (~markdown~) associated with: =.Rmd=, =.rmd= + CSV :: associated with: =.csv= + TSV :: (~csv~) associated with: =.tsv= ++ AsciiDoc :: (~docbook~) associated with: =.adoc=, =.asciidoc= -Currently /Rmarkdown/ and /TSV/ files require ~sed~ in order to pre-process the file -for Pandoc. +Currently + +- /Rmarkdown/ and /TSV/ files require ~sed~ +- /AsciiDoc/ requires [[https://github.com/asciidoctor/asciidoctor][~asciidoctor~]] + +in order to pre-process the file for Pandoc. ** Default transient-mode backends Please note that this mode is off by default. @@ -92,6 +97,7 @@ When ~ox-pandoc~ is available, the following formats are also enabled by default and use ~ox-pandoc~ to export. + =rst= + =docx= ++ =txt= :: using ~~org-pandoc-export-to-asciidoc~ * Adding new backends For something supported out of the box by Pandoc, it couldn't be easier --- diff --git a/org-pandoc-import-transient.el b/org-pandoc-import-transient.el index 6de893b..22b8b94 100644 --- a/org-pandoc-import-transient.el +++ b/org-pandoc-import-transient.el @@ -36,7 +36,8 @@ This trades a short blocking period for a long non-blocking period." "orgtbl-to-tsv")))) (when (featurep 'ox-pandoc) '(("rst" . org-pandoc-export-to-rst) - ("docx" . org-pandoc-export-to-docx)))) + ("docx" . org-pandoc-export-to-docx) + ("txt" . org-pandoc-export-to-asciidoc)))) "An alist of file extensions, and associated exporters. Exporters can either be a string correspanding to a particular org exporter, or a funcion that operates on the current buffer, and requires no arguments. diff --git a/org-pandoc-import.el b/org-pandoc-import.el index a98840f..654d3d2 100644 --- a/org-pandoc-import.el +++ b/org-pandoc-import.el @@ -373,7 +373,8 @@ if no such match could be found." (org-pandoc-import-backend rmarkdown '("rmd" "Rmd") "markdown") (org-pandoc-import-backend ipynb) (org-pandoc-import-backend csv) - (org-pandoc-import-backend tsv '("tsv") "csv"))) + (org-pandoc-import-backend tsv '("tsv") "csv") + (org-pandoc-import-backend asciidoc '("adoc" "asciidoc" "txt") "docbook"))) (provide 'org-pandoc-import) diff --git a/preprocessors/asciidoc.el b/preprocessors/asciidoc.el new file mode 100644 index 0000000..6385ba8 --- /dev/null +++ b/preprocessors/asciidoc.el @@ -0,0 +1,16 @@ +;;; org-pandoc-import/preprocessors/asciidoc.el --- Pre-process AsciiDoc files before importing -*- lexical-binding: t; -*- +;;; SPDX-License-Identifier: GPL-3.0-or-later + +(defun org-pandoc-import-asciidoc-preprocessor (in-file) + (let ((processed-file (make-temp-file "opif" nil ".dbk")) + (stderr-file (make-temp-file "opif" nil ".err"))) + (call-process (executable-find "asciidoctor") nil + (list `(:file ,processed-file) stderr-file) nil + "--backend" "docbook" "--out-file" "-" in-file) + ;; Dispatch stderr to *Warnings* buffer if there is any + (if (< 0 (file-attribute-size (file-attributes stderr-file))) + (with-temp-buffer + (insert-file-contents stderr-file) + (warn (buffer-string)))) + (message processed-file) + processed-file))