Skip to content

Instantly share code, notes, and snippets.

@elliottslaughter
Created May 15, 2015 01:46
Show Gist options
  • Save elliottslaughter/50eddc705e2d49bb6786 to your computer and use it in GitHub Desktop.
Save elliottslaughter/50eddc705e2d49bb6786 to your computer and use it in GitHub Desktop.
Deindent
import Data.List
import Text.Pandoc.Definition
import Text.Pandoc.JSON
import Text.Pandoc.Walk
-- This pass implements <div class="noindent"> by adding \noindent to
-- the start of every paragraph.
deindentParas :: Block -> Block
deindentParas (Para lines) =
Para (RawInline (Format "tex") "\\noindent " : lines)
deindentParas x = x
deindentBlocks :: Block -> Block
deindentBlocks (Div (id, classes, other) blocks) =
if elem "noindent" classes
then Div (id, (delete "noindent" classes), other) (walk deindentParas blocks)
else Div (id, classes, other) blocks
deindentBlocks x = x
main :: IO ()
main = toJSONFilter deindentBlocks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment