Write Pandoc filters in Scala.
Scala
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
project
src
.gitignore
.travis.yml
README.md
build.sbt

README.md

Spandoc

Write Pandoc filters in Scala. Very early release. Still in development.

Copyright 2016 Dave Gurnell. Licensed Apache 2.

Build Status Coverage status Maven Central

Getting Started

Grab this library in an Ammonite script and use it with Pandoc's --filter parameter. Here's an example script:

// Filename: filter.scala
#!/usr/bin/env amm

import ammonite.repl._

interp.load.ivy("com.davegurnell" %% "spandoc" % "<<VERSION>>")

@

import spandoc._

// Define a transform. This one only transforms "inline" elements:
val uppercase = transofrm.TopDown.inline {
  case Str(str) =>
    Str(str.toUpperCase)
}

// Run the transform on stdin, printing the result to stdout:
transformStdin(uppercase)

Then run Pandoc using the --filter option to point to filter.scala:

bash$ echo 'Lorem ipsum' | pandoc --to=html --filter=./filter.scala
<p>LOREM IPSUM</p>