#!/bin/bash
# doc/tool/pandoc - pandoc document converter tool
set -e
lib_load 'doc/tool/latex'
######
# Native Dependencies
doc_tool_pandoc_client_packages=( pandoc )
######
# Library Configuration
doc_tool_pandoc_config_init() {
lib_setting_vars pandoc_verbose
pandoc_verbose=${pandoc_verbose:-false}
lib_setting_vars --null pandoc_color_style
lib_setting_vars --null pandoc_input_format pandoc_output_format
lib_setting_vars --null pandoc_output_file
}
######
# Internal API
pandoc_run() {
local -a opts
! $pandoc_verbose || opts+=( --verbose )
[ -z "$pandoc_color_style" ] \
|| opts+=( --highlight-style "$pandoc_color_style" )
[ -z "$pandoc_input_format" ] \
|| opts+=( --read "$pandoc_input_format" )
[ -z "$pandoc_output_format" ] \
|| opts+=( --write "$pandoc_output_format" )
[ -z "$pandoc_output_file" ] \
|| opts+=( --output "$pandoc_output_file" )
run pandoc "${opts[@]}" "$@"
}
######
# Document Format Support
pandoc_input_formats() { pandoc_run --list-input-formats; }
pandoc_output_formats() { pandoc_run --list-output-formats; }
pandoc_color_langs() { pandoc_run --list-highlight-languages; }
pandoc_color_styles() { pandoc_run --list-highlight-styles; }
######
# Document Conversion
pandoc_convert_file() {
has_args 2 "$@"
local pandoc_output_file=$2
pandoc_run "$1"
}
######
# Document Conversion CLI
pandoc_dispatch() { lib_cmd_dispatch pandoc "$@"; }
pandoc_usage() {
cat <<USAGE
...
Pandoc Commands:
show ... Display supported pandoc features
convert ... Converts documents
USAGE
}
pandoc_show() { cmd_dispatch "$@"; }
pandoc_show_usage() {
cat <<USAGE
...
Pandoc Query Commands:
styles Prints highlight syles
languages Prints highlightable languages
readers Prints supported input formats
writers Prints supported output formats
USAGE
}
pandoc_convert() { cmd_dispatch "$@"; }
pandoc_convert_usage() {
cat <<USAGE
...
Pandoc Conversion Commands:
file <src> <dst> Convert a single document
USAGE
}
Generated on Tue Apr 25 21:20:56 PDT 2017 by mcsh i7 v0.18.0.