Pandoc Syntax
Themes/Styling
The content is being converted well, now how can I customize the converted document look and feel?
Pandoc has its:
-
templates in '~/hbrew/Cellar/pandoc/version-nbr/share/x86_64-osx-ghc-8.0.2/templates' or …/docx or …/odt
-
styling process may be:
-
docbook → xslt → xsl-fo → docx (really msword xml files)
-
OR docbook → xslt → docx
-
-
'Overview of XSL Xpath and XSL FO (Beginner Level),' https://www.youtube.com/watch?v=YWAX2B24Oyc
-
'XSL Formatting Objects,' http://www.ibiblio.org/xml/books/bible3/chapters/ch16.html.
Asciidoctor has its:
-
templates where?
-
styling process may be asciidoc → yaml and asciidoctor-pdf → pdf
-
'Asciidoctor PDF Theming Guide,' https://github.com/asciidoctor/asciidoctor-pdf/blob/master/docs/theming-guide.adoc.
Usage
The goal is to convert asciidoc (.adoc or .txt) files to html, docx and pdf. Here are sample commands to do that.
From experimenting, docbook seems to be a format that keeps all of the layout of asciidoc. Therefore, to generate a docbook xml file:
-
asciidoctor -b docbook filename.adoc
Note: asciidoctor is a ruby gem that was installed in folder '/usr/local/bin.'
Converting to docx:
-
pandoc -f docbook -t docx -o filename.docx filename.xml
Converting to pdf:
-
pandoc -f docbook -o pdf -o filename.pdf filename.xml
-
good but had missing borders around tables
-
-
OR asciidoctor-pdf filename.adoc
-
did a nice job
-
Refs:
1 'Using AsciiDoc and Asciidoctor to write documentation - Tutorial,' http://www.vogella.com/tutorials/AsciiDoc/article.html 1 'AsciiDoc cheatsheet,' https://powerman.name/doc/asciidoc 1 http://asciidoctor.org/ 1 'AsciiDoc Frequently Asked Questions,' http://asciidoc.org/faq.html 1 'How to Convert AsciiDoc to PDF with Asciidoctor,' http://asciidoctor.org/docs/convert-asciidoc-to-pdf/ 1 'Asciidoctor PDF Theming Guide,' https://github.com/asciidoctor/asciidoctor-pdf/blob/master/docs/theming-guide.adoc
Using Homebrew
Update: Wed, 2017-02-22
I had switched to Homebrew, several years earlier. It is lightweight and flexible as to where I can install it. Pandoc requires Latex to be installed before I can use it. I could not install Latex in a user account, but it worked from the admin. Here are the terminal commands:
-
to install the caskroom for homebrew:
-
brew cask search basictex
-
-
to install the software package installer into the admin’s '/usr/local/Caskroom/basictex/2016.1009' folder:
-
brew cask install basictex
-
-
in the finder, go to '/usr/local/Caskroom/basictex/2016.1009'
-
double click on the package to start the installer
-
follow it’s instructions.
The Latex utilities were placed in folder '/usr/local/texlive/2016basic/bin/x86_64-darwin' with a sibling folder of 'universal-darwin' as well. This path will probably need to be added to the shell profile or rc file.
Using Macport
For various reasons, I use the Textile markup language for documentation. The Pandoc text conversion library converts it to other formats. I have pandoc installed through macports. Here is an example syntax to convert to rtf:
-
pandoc -r textile -s -w rtf -o pma_test_table_backup.rtf pma_test_table_backup.textile
where:
-
'-r textile' is the read input file format
-
'-s' is the switch to create a standalone document with pandoc’s builtin output file format template
-
'-w rtf' is to write out in the rtf format
-
'-o output_filename.rtf' is the output file name, i.e. pma_test_table_backup.rtf
-
'input_filename.textile' is the input file name, i.e. pma_test_table_backup.textile
To see the format of the builtin standalone template file use:
-
"pandoc -D 'output_format'" i.e. pandoc -D rtf
'Use Pandoc to Easily Convert Text File To PDF or eBook Format' has a nice summary of the conversion syntax for html, open document format, pdf and epub.
— MarlonAGriffith - 29 Aug 2013