pandoc-filter-indent: Pandoc filter formatting Haskell code fragments using GHC lexer.

[ bsd3, library, program, text ] [ Propose Tags ] [ Report a vulnerability ]

Formats marked code fragments, and allows pandoc to safely process rest of your literate program. Mark code blocks with .haskell attribute:

```{.haskell}
-- your code here
```

Usage:

stack install pandoc-filter-indent
pandoc --filter pandoc-filter-indent -f input.md -o output.pdf
pandoc --filter pandoc-filter-indent -f input.md -o output.html

Using lhs2TeX is somewhat inconvenient on large Markdown documents processed with pandoc, since it assumes that it can freely redefine everything. It is also pretty heavy on learning.

So instead we have a simple Pandoc filter that is only applied to CodeFragments and creates tabular code structures from indentation. It uses GHC lexer to assure that latest features are always parsed correctly.

Please see the README on GitHub at https://github.com/migamake/pandoc-filter-typeset-code#readme


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.2.0.0, 0.2.1.0, 0.2.2.0, 0.2.3.0, 0.3.0.0, 0.3.1.0, 0.3.2.0, 0.3.3.0, 0.3.3.1
Change log ChangeLog.md
Dependencies base (>=4.7 && <5), blaze-html (>=0.9.2 && <1), blaze-markup (>=0.8.3 && <1), containers (>=0.6.7 && <1), ghc-syntax-highlighter (>=0.0.12 && <1), HaTeX (>=3.23.0 && <4), optics-core (>=0.4.1 && <1), optics-th (>=0.4.1 && <1), optparse-applicative (>=0.19.0 && <1), pandoc-filter-indent, pandoc-types (>=1.23.1 && <2), skylighting (>=0.14.7 && <1), text (>=2.0.2 && <3) [details]
License BSD-3-Clause
Copyright AllRightsReserved
Author Michał J. Gajda
Maintainer mjgajda@migamake.com
Category Text
Home page https://github.com/migamake/pandoc-filter-typeset-code#readme
Bug tracker https://github.com/migamake/pandoc-filter-typeset-code/issues
Source repo head: git clone https://github.com/migamake/pandoc-filter-typeset-code
Uploaded by MichalGajda at 2025-11-17T02:02:24Z
Distributions
Executables pandoc-filter-indent
Downloads 1058 total (5 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2025-11-17 [all 1 reports]

Readme for pandoc-filter-indent-0.3.3.0

[back to package description]

pandoc-filter-indent

Pandoc filter that intelligently typesets code by detecting indentation boundaries and aligning operators.

Quick Start

Install via Stack:

stack install pandoc-filter-indent

Use with Pandoc:

pandoc --filter pandoc-filter-indent input.md -o output.pdf
pandoc --filter pandoc-filter-indent input.md -o output.html

What it does

Transforms code blocks into well-aligned, tabular layouts that highlight code structure. Instead of plain monospaced code, you get properly aligned operators, function signatures, and nested structures.

Input:

```{.haskell}
class Eq      a
   => Compare a where
  compare :: a -> a -> Ordering
  (>=)    :: a -> a -> Bool
```

Output: Rendered with operators vertically aligned in clean tables, using mathematical symbols (→, ⇒, ≥) in LaTeX/PDF output.

Features

  • Smart alignment - Detects and aligns operators (::, =, ->, etc.) using GHC lexer
  • Multiple languages - Haskell (GHC), Python, or generic indentation-based formatting
  • Flexible output - LaTeX tables, HTML tables, or Pandoc native tables
  • Symbol beautification - Converts operators to mathematical symbols (optional)
  • Lightweight - Simple Pandoc filter, easy to integrate

Usage

Mark code blocks with language attribute:

```{.haskell}
-- your Haskell code
```

Or use alternate lexers:

```{.python}
# your Python code
```

For generic indentation-based alignment:

```{.haskell lexer=indent}
-- any indented code
```

Options

Configure via code block attributes:

  • lexer=haskell - GHC lexer (default)
  • lexer=python3 - Python lexer
  • lexer=indent - Indent-only alignment
  • lexer=spaces - Space-based alignment
  • debug=true - Show column boundaries for debugging

Example:

```{.haskell debug=true}
yourCode :: Here
```

Full Documentation

For detailed algorithm explanation, implementation guide, and advanced usage, see DESCRIPTION.md.

See also: Complete Unicode operator symbol mapping for all supported operator conversions (→, ⇒, ≥, ⊥, ∅, etc.).

License

BSD3 - see LICENSE file