Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added AsciiDoc backend #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions README.org
Original file line number Diff line number Diff line change
@@ -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 ---
3 changes: 2 additions & 1 deletion org-pandoc-import-transient.el
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 2 additions & 1 deletion org-pandoc-import.el
Original file line number Diff line number Diff line change
@@ -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 changes: 16 additions & 0 deletions preprocessors/asciidoc.el
Original file line number Diff line number Diff line change
@@ -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))