Skip to content

Commit

Permalink
Enhanced interface to pandoc
Browse files Browse the repository at this point in the history
  • Loading branch information
fadado committed Dec 3, 2018
1 parent 40da1b4 commit 5c51d01
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 116 deletions.
90 changes: 16 additions & 74 deletions bin/jqt
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ function usage
function help
{
cat <<'EOF'
Usage: jqt [-h | --help | -p | -V | --version]
Usage: jqt [-h | -p | -V ]
jqt [options] < infile > result
jqt [options] infile > result
jqt [options] infile result
Expand All @@ -552,10 +552,10 @@ Preprocessor options Data options
Template options -C
-L DIRECTORY -H
-i MODULE -S
-j MODULE:NAME Information options
Document options -h, --help
-j NAME:MODULE Information options
Document options -h
-4, -5 -p
-d FILE -V, --version
-d FILE -V
See the manpage for full documentation and more options.
EOF
Expand All @@ -564,37 +564,16 @@ EOF

function pandoc_options
{
echo 'Pandoc options:'
cat <<'EOF' | pr -e --omit-pagination --indent=4 --width=100 --columns=2
--base-header-level=NUMBER
--bibliography=FILE
--citation-abbreviations=FILE
--columns=NUMBER
--csl=FILE
--email-obfuscation=none|javascript|references
--file-scope
--gladtex
--highlight-style=STYLE
--html-q-tags
--id-prefix=STRING
--indented-code-classes=CLASSES
--jsmath[=URL]
--katex[=URL]
--katex-stylesheet
--latexmathml[=URL]
--mathjax[=URL]
--mathml[=URL]
--mimetex[=URL]
--no-highlight
--normalize
--number-offset=NUMBER[,NUMBER,...]
--number-sections
--preserve-tabs
--section-divs
--tab-stop=NUMBER
--toc-depth=NUMBER
--webtex[=URL]
--wrap=[auto|none|preserve]'
cat <<'EOF'
jqt will forward to pandoc all long options present in the command line, but
some are reserved or have no meaning (be careful).
Pandoc options used internally by jqt (do not play with them):
--from
--to
--template
--table-of-contents
--output
EOF
exit 0
}
Expand Down Expand Up @@ -712,45 +691,8 @@ while getopts :hVD:I:P:L:i:j:45d:weprt:m:M:T:CHS-: opt; do
# '--' end options
:) break
;;
# Generic options
help) help
;;
version) echo "$SELF $VERSION"; exit 0
;;
datadir) echo "${DATADIR}"; exit 0
;;
# Pandoc options:
base-header-level=*) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
bibliography=*) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
citation-abbreviations=*) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
columns=*) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
csl=*) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
email-obfuscation=*) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
file-scope) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
gladtex) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
highlight-style=*) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
html-q-tags) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
id-prefix=*) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
indented-code-classes=*) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
jsmath|jsmath=*) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
katex-stylesheet=*) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
katex|katex=*) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
latexmathml|latexmathml=*) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
mathjax|mathjax=*) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
mathml|mathml=*) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
mimetex|mimetex=*) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
no-highlight) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
normalize) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
number-offset=*) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
number-sections) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
preserve-tabs) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
section-divs) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
tab-stop=*) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
toc-depth=*) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
webtex|webtex=*) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
wrap=*) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG";;
# Errors
*) usage "Unknown option: --$OPTARG"
# Errors (warning: bad options produce unexpected failures).
*) PANDOC_OPTS[${#PANDOC_OPTS[@]}]="--$OPTARG"
;;
esac # end case --*
;;
Expand Down
14 changes: 14 additions & 0 deletions docs/Sakefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ JQTFLAGS += -5 --toc-depth=4 #-S

$(PagesHTML): $(Blocks)/filters.jq

tree:
tree \
-J \
$(Root) \
-P '*.html' \
--dirsfirst

# -H $(Root)
# -T "Sitemap"
# -o $@

purge:
killall jqt jq pandoc

depend: $(Meta)/phase3d.make
cat $< | egrep -v '^#|^$$' | cut -c -72 - | sed 's/$$/.../'

Expand Down
44 changes: 11 additions & 33 deletions docs/content/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,42 +197,20 @@ is, the ampersand and the newline are removed and effectively ignored).

### Pandoc’s Markdown

<%cite jqt> accept as input format for documents the [Pandoc's MarkDown](http://pandoc.org/MANUAL.html#pandocs-markdown)
<%cite jqt> accepts as input format for documents the [Pandoc's MarkDown](http://pandoc.org/MANUAL.html#pandocs-markdown)
variant, with the <a href="http://pandoc.org/MANUAL.html#extension-pandoc_title_block">title block extension</a>
disabled, and produces by default transitional HTML. When running `jqt` the following
Pandoc long options can be specified in
the command line and will be forwarded untouched to `pandoc`:
disabled, and produces by default transitional HTML. When running `jqt` all
long options specified in the command line will be forwarded
untouched to `pandoc`, but some are reserved or have no meaning.

<%cite Pandoc> options used internally by <%cite jqt> (do not play with them):

```
--base-header-level=NUMBER
--bibliography=FILE
--citation-abbreviations=FILE
--columns=NUMBER
--csl=FILE
--email-obfuscation=none|javascript|references
--file-scope
--gladtex
--highlight-style=STYLE
--html-q-tags
--id-prefix=STRING
--indented-code-classes=CLASSES
--jsmath[=URL]
--katex[=URL]
--katex-stylesheet
--latexmathml[=URL]
--mathjax[=URL]
--mathml[=URL]
--mimetex[=URL]
--no-highlight
--normalize
--number-offset=NUMBER[,NUMBER,...]
--number-sections
--preserve-tabs
--section-divs
--tab-stop=NUMBER
--toc-depth=NUMBER
--webtex[=URL]
--wrap=[auto|none|preserve]
--from=FORMAT
--to=FORMAT
--template=FILE
--table-of-contents
--output=FILE
```

<#
Expand Down
5 changes: 3 additions & 2 deletions docs/content/engine.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ arguments. The usage possibilities are:
| **jqt** [**-h** | **--help** | **-p** | **-V** | **--version**]
| **jqt** [_options_] < _infile_ > _result_
| **jqt** [_options_] _infile_ > _result_
| **jqt** [_options_] _infile_ _result_
**jqt** [_options_] _infile_ _result_

### Options

Expand Down Expand Up @@ -106,7 +106,8 @@ Block comment `<# #>` `<# #>` `/* */` `/*
Line comment `//` `//`
Bypass[^1] `<!-- -->` `<!-- -->`
`` ` ` ``
`\n~~~` (also backticks)
<code>\\n&#96;&#96;&#96;</code>
`\n~~~`
Escape[^2] `` ` ` `` `` ` ` ``
String[^3] `{% %}` `" "` `" "`
`{{ }}` `' '`
Expand Down
2 changes: 1 addition & 1 deletion docs/content/opt/V.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-V, --version
-V
: Displays version information.
<#
vim:ts=4:sw=4:ai:et:fileencoding=utf8:syntax=markdown
Expand Down
2 changes: 1 addition & 1 deletion docs/content/opt/h.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-h, --help
-h
: Displays this message.
<#
vim:ts=4:sw=4:ai:et:fileencoding=utf8:syntax=markdown
Expand Down
6 changes: 3 additions & 3 deletions docs/content/structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ Table: **Delimiters used in <%cite jqt> templates**
#### Expressions

The text in expressions and actions is normal [_jq_][JQ] code, where as
a bonus, the `$M` global variable points to the `jq` JSON input (the initial `.`).
a bonus, the `$jqt` global variable points to the `jq` JSON input (the initial `.`).
The rules for expression evaluation are very simple:

* If an expression evaluates to `empty` the whole line vanishes.
Expand Down Expand Up @@ -217,14 +217,14 @@ The evaluation rules for one line actions are as follows:
* If the delimited snippet evaluates to `empty` the whole line vanishes.
* Otherwise, for each value produced the text following the
snippet is evaluated with the value assigned to the dot (`.`). The initial
dot is still available in the global variable `$M`.
dot is still available in the global variable `$jqt`.

The evaluation rules for multiline actions are as follows:

* If the opening snippet evaluates to `empty` all lines until the ending snippet disappear.
* Otherwise, for each value produced the lines until the ending snippet
are evaluated with the value assigned to the dot (`.`). The initial dot is
still available in the global variable `$M`.
still available in the global variable `$jqt`.

<# Warning: raw blocks are not documented because they are CONTENT! #>

Expand Down
7 changes: 5 additions & 2 deletions share/sake.d/main.make
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ $(sake_builtin): ; @echo 'sake: Target `$@` not implemented.'
build:: $(PagesHTML)
@cp --verbose --recursive --update $(Assets)/* $(Root) \
| sed "s/^.*-> ./==> /;s/.$$//"
date -Iseconds > $(Meta)/lastbuild
echo Done! Visit file://$(realpath $(Root))/index.html

# Delete secondary files.
clobber:: ; @rm -rf *~ *.bak *.log
Expand Down Expand Up @@ -176,6 +174,11 @@ $(MDIR)/sitemap.make: ;
$(MDIR)/styles.make: ;
$(MDIR)/tools.make: ;

# Bye
build::
date -Iseconds >> $(Meta)/lastbuild
echo Done! Visit file://$(realpath $(Root))/index.html

endif # __phase_3
endif # __phase_2
endif # __phase_1
Expand Down

0 comments on commit 5c51d01

Please sign in to comment.