View Source Pandoc (pandoc v0.3.2)

Pandoc is an installer, runner and watcher for pandoc.

Profiles

You can define multiple pandoc profiles. By default, there is a profile called :default which you can configure its args, current directory and environment. You can make the args dynamic by defining a function.

config :pandoc,
  version: "3.6.1",
  default: [
    args: fn extra_args ->
      {_, [input_file], _} = OptionParser.parse(extra_args, switches: [])
      ~w(--output=../priv/static/posts/#{Path.rootname(input_file)}.html)
    end,
    cd: Path.expand("../documents", __DIR__)
  ]

Pandoc configuration

There are four global configurations for the pandoc application:

  • :version - the expected pandoc version

  • :version_check - whether to perform the version check or not. Useful when you manage the pandoc executable with an external tool

  • :cacerts_path - the directory to find certificates for https connections

  • :path - the path to find the pandoc executable at. By default, it is automatically downloaded and placed inside the _build directory of your current app

Overriding the :path is not recommended, as we will automatically download and manage pandoc for you. But in case you can't download it, you may want to set the :path to a configurable system location.

Summary

Functions

Returns the path to the executable.

Returns the version of the pandoc executable.

Returns the configuration for the given profile.

Returns the configured pandoc version.

The default URL to install Pandoc from.

Installs, if not available, and then runs pandoc.

Runs the given command with args.

Starts a file system watcher that runs the given command with args when a file event is received for a file that matches the given pattern.

Functions

bin_path()

Returns the path to the executable.

The executable may not be available if it was not yet installed.

bin_version()

Returns the version of the pandoc executable.

Returns {:ok, version_string} on success or :error when the executable is not available.

config_for!(profile)

Returns the configuration for the given profile.

Returns nil if the profile does not exist.

configured_version()

Returns the configured pandoc version.

default_base_url()

The default URL to install Pandoc from.

install(base_url \\ default_base_url())

Installs pandoc with configured_version/0.

If invoked concurrently, this task will perform concurrent installs.

install_and_run(profile, args)

Installs, if not available, and then runs pandoc.

This task may be invoked concurrently and it will avoid concurrent installs.

Returns the same as run/2.

run(profile, extra_args)

Runs the given command with args.

The given args will be appended to the configured args. The task output will be streamed directly to stdio. It returns the status of the underlying call.

watch(profile, extra_args \\ [], pattern \\ ~r/\.md$/)

Starts a file system watcher that runs the given command with args when a file event is received for a file that matches the given pattern.

The given args will be appended to the configured args. The task output will be streamed directly to stdio.