2025-10-12 23:23:28 +08:00
2025-10-11 09:14:33 +08:00
2025-10-12 23:22:04 +08:00
2025-10-12 23:09:00 +08:00
2025-10-11 09:14:33 +08:00
2025-10-12 23:22:04 +08:00
2025-10-11 11:49:38 +08:00

Piecewise Readable Filter

This is a pandoc filter manipulating fenced_divs in pandoc markdown.

Inspired by this joke.

useful refs:

How does this work?

filter.lua walks the AST. There are some special leaf nodes with a include attr which is a string containing labels of some other divs to be included here.

For each of include node i, we maintain a list fa[i] containing nodes with labels on the path i -> root. Then for each label l in i's include list, one can see that every node in fa[i] depends on l. Thus we build a digraph G on labels. If G is a DAG, then we can use topological sort to rank its vertices and thus decide the order of substitution; Otherwise, G contains a directed cycle, the filter reports an error.

Description
No description provided
Readme Unlicense 102 KiB
Languages
Lua 82.6%
HTML 14.6%
Makefile 2.8%