Skip to content

Instantly share code, notes, and snippets.

@edwtjo
Created October 2, 2016 07:37
Show Gist options
  • Save edwtjo/b32b2394fba7257b62d4ba5223807b94 to your computer and use it in GitHub Desktop.
Save edwtjo/b32b2394fba7257b62d4ba5223807b94 to your computer and use it in GitHub Desktop.
A Pandoc Filter for Comments (install nix and chmod to use)
#! /usr/bin/env nix-shell
#! nix-shell -i runghc -p "haskellPackages.ghcWithPackages (p: with p; [pandoc])"
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/7465bcd67a2177c63adeec66398b1b581260b31e.tar.gz
import Text.Pandoc.JSON
removeComments :: Block -> IO Block
removeComments cb@(CodeBlock (id, classes, namevals) contents) =
if "comment" `elem` classes then
return $ Para []
else return cb
removeComments x = return x
main :: IO ()
main = toJSONFilter removeComments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment