All Projects → htdebeer → pandocomatic

htdebeer / pandocomatic

Licence: GPL-3.0 license
Automate the use of pandoc

Programming Languages

ruby
36898 projects - #4 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to pandocomatic

pandoc-bash-blog
A static blog generator based on Pandoc and Bash
Stars: ✭ 16 (-86.99%)
Mutual labels:  static-site-generator, pandoc
slipbox
A static site generator for Zettelkasten notes
Stars: ✭ 32 (-73.98%)
Mutual labels:  static-site-generator, pandoc
bulbo
🍹 Generate your static site with gulp plugins!
Stars: ✭ 14 (-88.62%)
Mutual labels:  static-site-generator
vue-static
A static site generator made in Vue. The power and navigation speed of a SPA with the SEO and loading speed of a static site. Based on React-Static.
Stars: ✭ 25 (-79.67%)
Mutual labels:  static-site-generator
Align
a single static blog generater use vue components and markdown files
Stars: ✭ 92 (-25.2%)
Mutual labels:  static-site-generator
uiucthemes
RMarkdown Templates for UIUC Theme-Oriented Documents
Stars: ✭ 45 (-63.41%)
Mutual labels:  pandoc
bookends-tools
Alfred Workflow to Integrate with Bookends, an academic reference manager/bibliography tool for macOS
Stars: ✭ 78 (-36.59%)
Mutual labels:  pandoc
dendron-site
Getting started with Dendron
Stars: ✭ 99 (-19.51%)
Mutual labels:  static-site-generator
pandoc-latex-environment
Pandoc filter for adding LaTeX environement on specific div
Stars: ✭ 27 (-78.05%)
Mutual labels:  pandoc
casile
The CaSILE toolkit, a book publishing workflow employing SILE and other wizardry.
Stars: ✭ 36 (-70.73%)
Mutual labels:  pandoc
hugo-minimalist-theme
Port of Raphael Riegger's Minimalistic Ghost theme to Hugo.
Stars: ✭ 25 (-79.67%)
Mutual labels:  static-site-generator
iron-beard
Simple, zero-configuration static site generator written in .NET Core.
Stars: ✭ 26 (-78.86%)
Mutual labels:  static-site-generator
contentful-export
Extract Contentful to Hugo
Stars: ✭ 22 (-82.11%)
Mutual labels:  static-site-generator
gedit-plugin-markdown preview
A gedit plugin previewing markdown (.md) documents
Stars: ✭ 79 (-35.77%)
Mutual labels:  pandoc
citeproc-rs
CSL processor in Rust.
Stars: ✭ 56 (-54.47%)
Mutual labels:  pandoc
crisp-react
React boilerplate written in TypeScript with a variety of Jamstack and full stack deployments. Comes with SSR and without need to learn a framework. Helps to split a monolithic React app into multiple SPAs and avoid vendor lock-in.
Stars: ✭ 147 (+19.51%)
Mutual labels:  static-site-generator
wordpress-scaffold
The scaffold for GRRR's WordPress Pro setup.
Stars: ✭ 16 (-86.99%)
Mutual labels:  static-site-generator
chronicle2
Chronicle is a simple blog compiler, written in Perl with minimal dependencies.
Stars: ✭ 19 (-84.55%)
Mutual labels:  static-site-generator
static-roam
A static-site generator for Roam Research
Stars: ✭ 59 (-52.03%)
Mutual labels:  static-site-generator
pandoc-templates
An opinionated set of Pandoc templates and scripts for converting markdown to DOCX manuscripts that adhere to William Shunn's Proper Manuscript Format guidelines using Pandoc.
Stars: ✭ 30 (-75.61%)
Mutual labels:  pandoc

Gem Version

Pandocomatic—Automate the use of pandoc

Pandocomatic is a tool to automate the use of pandoc. With pandocomatic you can express common patterns of using pandoc for generating your documents. Applied to a directory, pandocomatic can act as a static site generator. For example, this manual is generated with pandocomatic!

Pandocomatic is free software; pandocomatic is released under the GPLv3. You will find the source code of pandocomatic in its repository on Github.

Note. Pandocomatic is build on top of paru, which is a wrapper around pandoc.

Note. As I am a GNU/Linux user, I do not officially support other operating systems like Mac OSX or Windows. Fixes and patches for those operating systems are welcome.

See pandocomatic’s manual for an extensive description of pandocomatic.

Why pandocomatic?

I use pandoc a lot. I use it to write all my papers, notes, websites, reports, outlines, summaries, and books. Time and again I was invoking pandoc like:

pandoc --from markdown \
  --to html \
  --standalone \
  --csl apa.csl \
  --bibliography my-bib.bib \
  --mathjax \
  --output result.html \
  source.md

Sure, when I write about history, the CSL file and bibliography change. And I do not need the --mathjax option like I do when I am writing about mathematics education. Still, all these invocations are quite similar.

I already wrote the program do-pandoc.rb as part of a Ruby wrapper around pandoc, paru. Using do-pandoc.rb I can specify the options to pandoc in a metadata block in the source file itself. With do-pandoc.rb the invocation above is simplified to:

do-pandoc.rb source.md

It saves me from typing out the whole pandoc invocation each time I run pandoc on a source file. However, I have still to setup the same options to use in each document that I am writing, even though these options do not differ that much from document to document.

Pandocomatic is a tool to re-use these common configurations by specifying a so-called pandocomatic template in a YAML configuration file. For example, by placing the following file, pandocomatic.yaml, in pandoc’s data directory:

templates:
  education-research:
    preprocessors: []
    pandoc:
      from: markdown
      to: html
      standalone: true
      csl: 'apa.csl'
      toc: true
      bibliography: /path/to/bibliography.bib
      mathjax: true
    postprocessors: []

In this configuration file a single pandocomatic template is being defined: education-research. This template specifies that the source files it is applied to are not being preprocessed. Furthermore, the source files are converted with pandoc by invoking pandoc --from markdown --to html --standalone --csl apa.csl --toc --bibliography /path/to/bibliography.bib --mathjax. Finally, the template specifies that pandoc’s output is not being postprocessed.

I now can create a new document that uses this template by including the following metadata block in my source file, on_teaching_maths.md:

 ---
 title: On teaching mathematics
 author: Huub de Beer
 pandocomatic_:
   use-template: education-research
   pandoc:
     output: on_teaching_mathematics.html
 ...
 
 Here goes the contents of my new paper ...

To convert this file to on_teaching_mathematics.html I run pandocomatic:

pandocomatic -i on_teaching_maths.md

With just two extra lines in a metadata block I can tell pandocomatic what template to use when converting a file. You can also use multiple templates in a document, for example to convert a markdown file to both HTML and PDF. Adding file-specific pandoc options to the conversion process is as easy as adding a pandoc property with those options to the pandocomatic_ metadata property in the source file like I did with the output property in the example above.

Once I had written a number of related documents this way, it was a small step to enable pandocomatic to convert directories as well. Just like that, pandocomatic can be used as a static site generator!

Pandocomatic is free software; pandocomatic is released under the GPLv3. You find pandocomatic’s source code on github.

Installation

Pandocomatic is a Ruby program and can be installed through RubyGems as follows:

gem install pandocomatic

This will install pandocomatic and paru, a Ruby wrapper around pandoc. To use pandocomatic, you also need a working pandoc installation. See pandoc’s installation guide for more information about installing pandoc.

You can also download the latest gem, pandocomatic-0.3.α, from Github and install it manually as follows:

cd /directory/you/downloaded/the/gem/to
gem install pandocomatic-0.3.α.gem

Examples

Convert a single file

Convert hello.md to hello.html according to the configuration in pandocomatic.yaml:

pandocomatic --config pandocomatic.yaml -o hello.html -i hello.md

Convert a directory

Generate a static site using data directory assets, but only convert files that have been updated since the last time pandocomatic has been run:

pandocomatic --data-dir assets/ -o website/ -i source/ -m

Generating pandocomatic’s manual and README files

Generate the markdown files for pandocomatic’s manual and its github repository README:

git clone https://github.com/htdebeer/pandocomatic.git
cd documentation
pandocomatic -d data-dir -c config.yaml -i README.md -o ../README.md
pandocomatic -d data-dir -c config.yaml -i manual.md -o ../index.md

Be careful to not overwrite the input file with the output file! I would suggest using different names for both, or different directories. Looking more closely to the pandocomatic configuration file config.yaml, we see it contains one template, mddoc:

 templates:
   mddoc:
     pandoc:
       from: markdown
       to: markdown
       standalone: true
       filter: 
       - filters/insert_document.rb
       - filters/insert_code_block.rb
       - filters/remove_pandocomatic_metadata.rb
       - filters/insert_pandocomatic_version.rb
   indexdoc:
       extends: mddoc
       postprocessors: ['postprocessors/setup_for_website.rb']

The mddoc template tells pandocomatic to convert a markdown file to a standalone markdown file using three filters: insert_document.rb, insert_code_block.rb, and remove_pandocomatic_metadata.rb. The first two filters allow you to include another markdown file or to include a source code file (see the README listing below). The last filter removes the pandocomatic metadata block from the file so the settings in it do not interfere when, later on, manual.md is converted to HTML. These filters are located in the filters subdirectory in the specified data directory data-dir.

However, the mddoc template converts from and to pandoc’s markdown variant, which differs slightly from the markdown variant used by Github for README files. Luckily, pandoc does support writing Github’s markdown variant. There is no need to create and use a different template for generating the README, though, as you can override all template’s settings inside a pandocomatic block in a markdown file:

 ---
 pandocomatic_:
   use-template: mddoc
   pandoc:
     to: markdown_github
 ...
 
 # Pandocomatic—Automate the use of pandoc
 
 ::paru::insert introduction.md
 
 ## Why pandocomatic?
 
 ::paru::insert why_pandocomatic.md
 
 ## Licence
 
 ::paru::insert license.md
 
 ## Installation
 
 ::paru::insert install.md
 
 ## Examples
 
 ::paru::insert usage_examples.md
 
 ## More information
 
 See [pandocomatic's
 manual](https://heerdebeer.org/Software/markdown/pandocomatic/) for more
 extensive examples of using pandocomatic. Notably, the manual contains two
 typical use cases of pandocomatic:
 
 1.  [automating setting up and running pandoc for a series of related papers](https://heerdebeer.org/Software/markdown/pandocomatic/#automating-setting-up-and-running-pandoc-for-a-series-of-related-papers), and 
 2.  [using pandocomatic as a static site
      generator](https://heerdebeer.org/Software/markdown/pandocomatic/#using-pandocomatic-as-a-static-site-generator).

Here you see that the README uses the mddoc template and it overwrites the to property with markdown_github.

Similarly, in the input file manual.md, an extra filter is specified, ‘number_chapters_and_sections_and_figures.rb’, to number the chapters and sections in the manual, which is not needed for the README, by using the following pandocomatic metadata in the manual input file:

pandocomatic_:
  use-template: mddoc
  pandoc:
    filter: 
    - 'filters/number_chapters_and_sections_and_figures.rb'

Pandocomatic allows you to generalize common aspects of running pandoc while still offering the ability to be as specific as needed.

More information

See pandocomatic’s manual for more extensive examples of using pandocomatic.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].