Skip to main content

pandocker-lua-filters

Lua filters for pandoc

Install

  • installs as a python package for ease of use
    • pip install pandocker-lua-filters
  • Lua filters should be installed under <sys.prefix>/share/lua/{5.3|5.4}/pandocker where <sys.prefix> can be confirmed by python -c "import sys; print(sys.prefix)". It install both 5.3 and 5.4 directories no matter of actual lua versions in system. This <sys.prefix>/share/lua/{5.3|5.4} should be added to package.path which can be confirmed by lua -e "print(package.path)".

General use

Convert AAFigure ascii art

  • requires aafigure python package

aafigure.lua

Convert CSV into table

  • requires csv and penlight luarocks packages
  • Pandoc below 2.10 applies "simple" filters

csv2table.lua
csv2table-simple.lua

Replace title subtitle date author metadata

hide-frontpage-metadata

Text file listing

  • requires penlight luarocks package

listingtable.lua

Concatenate text files

preprocess.lua

Removable note block

removable-note.lua

Convert svgbob ascii art

svgbob.lua

Convert SVG images to other formats

  • requires rsvg-convert in $PATH
  • pandoc docx writer >= 3.1.10 will apply native feature

svgconvert.lua

Applies table attributes to a table

  • requires penlight luarocks package
  • Pandoc below 2.10 applies "simple" filters

table-width.lua
table-width-simple.lua

Wavedrom / Bit-Field

  • requires wavedrom-cli in $PATH (npm i -g wavedrom-cli)
  • requires lyaml and lua-cjson2 luarocks packages

wavedrom.lua

LaTeX output only

Landscape pages

tex-landscape.lua

Applies underline to .underline class span

tex-underline.lua

Docx output only

Inserts a comment

docx-comment.lua

Code block numbering

  • Soft wrap will collapse layout. Set up Source Code paragraph style properly.

docx-codeblock-linenumber.lua

Apply custom (paragraph) styles for each table cell

docx-apply-cell-styles.lua

Apply custom (paragraph) styles for image and its caption

docx-image-styles.lua

Apply custom (character) styles for any span

docx-custom-span-styles.lua

Apply in-place color for any span

docx-colored-span.lua

Apply custom (paragraph) styles for any unnumbered bullet lists

Finds unnumbered bullet lists down to 3rd level and applies custom paragraph styles. 4th level and lower list items are escalated to 3rd level.

docx-extract-bullet-lists.lua

Requirement for template
  • Prepare Bullet List 1 to Bullet List 3 paragraph styles (by the way this is 1st level list item)
    • Otherwise these headers inherit Body style (this is 2nd level)
Level Unnumbered
1 Bullet List 1
2 Bullet List 2
3+ Bullet List 3

TOC / Pagebreak / Linebreak / Sub section TOC

docx-pagebreak-toc.lua

  • Adds TOC(Table Of Contents), sub sections, a line break or a page break at any point of document
Requirement for template

TOC title is set to "Table of Contents" by default. Metadata toc-title overrides this setting.

Appendix headings

docx-appendixheadings.lua

  • Makes appendix class work to appendix headings in DOCX format
  • Limited to level-1 to 5 headings
Requirement for template
  • Prepare Appendix Heading 1 to Appendix Heading 5 heading styles
    • Otherwise these headers inherit Body style
Level Numbered Unnumbered
1 Heading 1 Appendix Heading 1
2 Heading 2 Appendix Heading 2
3 Heading 3 Appendix Heading 3
4 Heading 4 Appendix Heading 4
5 Heading 5 Appendix Heading 5
6 Heading 6

Unnumbered headings

docx-unnumberedheadings.lua

  • Makes UnnumberHeadings class work to unnumber headings in DOCX format
  • Limited to level-1 to 5 headings
Requirement for template
  • Prepare Heading Unnumbered 1 to Heading Unnumbered 5 heading styles
    • Otherwise these headers inherit Body style
Level Numbered Unnumbered
1 Heading 1 Heading Unnumbered 1
2 Heading 2 Heading Unnumbered 2
3 Heading 3 Heading Unnumbered 3
4 Heading 4 Heading Unnumbered 4
5 Heading 5 Heading Unnumbered 5
6 Heading 6

Tabularize figures WIP

docx-tabularize-figures.lua

  • Finds figurediv class Div
  • Gets col attribute
  • Tabularize images in the Div into a table size of col cols
  • Adds figurediv class for each images to avoid further process by docx-image-styles.lua
  • Compatible with pandoc-crossref
    • This filter must be applied before pandoc-crossref

Figure styles

docx-image-styles.lua

  • Processes only paragraph having single image link except figurediv class
    • Blank lines required before and after image link
  • Requires Graphic Anchor and Figure Caption paragraph styles in template otherwise these styles inherit Body style
    • the filter creates two divs having custom-style attribute
    • after process the image is placed in custom-style="Graphic Anchor" div and its caption is in custom-style="Figure Caption" div respectively
Requirement for template
  • Prepare Graphic Anchor and Figure Caption styles

samples

![Centered image](https://github.com/pandocker/pandoc-docx-utils-py/raw/master/qr.png){width=100mm #fig:centered}

Want a new feature?

Feature request (via issues) and PRs are welcome. Post questions in issues with [Q] in issue title.

DIY

As lua filters only requires pandoc itself, it is relatively easy to try develop a new filter. I recommend to use k4zuki/pandocker-alpine docker image like

  • docker pull k4zuki/pandocker-alpine to get image
  • clone this repo git clone git@github.com:pandocker/pandocker-lua-filters.git
  • cd pandocker-lua-filters
  • docker run --rm -it -v/$PWD:/workdir k4zuki/pandocker-alpine to start docker image
  • make install to install filters in image. They are installed in /usr/local/share/lua/5.3/pandocker/
  • make reinstall to reinstall so that filters will be updated
  • make uninstall to uninstall filters
  • make html|pdf|docx to compile test document
  • edit tests/Makefile to configure options for pandoc

You don't have to reinstall for every source code updates. Instead edit tests/Makefile to run your new filter from inside repository.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pandocker_lua_filters-0.0.41-py3-none-any.whl (3.4 MB view details)

Uploaded Python 3

File details

Details for the file pandocker_lua_filters-0.0.41-py3-none-any.whl.

File metadata

File hashes

Hashes for pandocker_lua_filters-0.0.41-py3-none-any.whl
Algorithm Hash digest
SHA256 f1922f55bbf76327123898034c59e626cde0ab8bec16b7652a3a91f86f2ecf95
MD5 d14d65063d2a4b36fd6dc0bd879954dd
BLAKE2b-256 f399bbc10738c55fb737e783aac5227d50d02ea46a23711c03961d9c2a658905

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page