Added AsciiDoc backend

This commit is contained in:
Declan Qian 2022-09-21 00:25:08 +08:00 committed by Declan Qian
parent d3cd2b0519
commit d17545a1dd
4 changed files with 28 additions and 4 deletions

View File

@ -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 ---

View File

@ -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.

View File

@ -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)

16
preprocessors/asciidoc.el Normal file
View File

@ -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))