Ruby JSON filter for the Apex Markdown processor, compatible with Pandoc-style filters (docs).
This filter:
- Looks for a document title in Pandoc JSON metadata (
meta.title). - If the first block is not already a level‑1 header (
Header 1), prepends anH1using that title.
The transformation is:
- Input: Pandoc JSON document (
Pandocobject) onstdin. - Output: Modified Pandoc JSON document on
stdout.
The main filter implementation lives in title.rb:
./title.rb < in.json > out.jsonIt expects a full Pandoc‑style JSON document as produced by:
pandoc -t json input.md | ./title.rb | pandoc -f json -t htmlor, when used via Apex:
apex --filter title input.md > output.html-
Ensure the script is executable:
chmod +x title.rb
-
Install it into your Apex filters directory:
mkdir -p ~/.config/apex/filters cp title.rb ~/.config/apex/filters/title
-
Run Apex with the filter enabled:
apex --filter title input.md > output.html
To run all installed filters in the directory:
apex --filters input.md > output.htmlYou can also combine this with other filters (e.g., delink) simply by
having multiple executables in ~/.config/apex/filters and/or using
multiple --filter NAME arguments.