Skip to content

Instantly share code, notes, and snippets.

@steshaw
Created May 3, 2020 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steshaw/98c479fa2ace9f3e4ce14f57cf4a0db6 to your computer and use it in GitHub Desktop.
Save steshaw/98c479fa2ace9f3e4ce14f57cf4a0db6 to your computer and use it in GitHub Desktop.
module Docs where
import Prelude
import Text.Pandoc
import Text.Pandoc.Walk
import qualified Data.Text.IO as T
go = do
t <- T.readFile "../.local/j.html";
pandoc1@(Pandoc meta1 blocks1) <- runIOorExplode $ readHtml def t;
putStrLn "\npandoc1 ---------------\n"
mapM_ print blocks1;
let pandoc_ = walk f pandoc1;
let pandoc2 = walk g pandoc_;
let (Pandoc _ blocks2) = pandoc2;
mapM_ print blocks2;
putStrLn "\npandoc2 ---------------\n"
t <- runIOorExplode $ writePlain def { writerTabStop = 2 } pandoc2;
putStrLn "\nplain ---------------\n"
T.putStrLn t
where
f :: Block -> Block
f (Para x) = Plain x
f a = a
g :: Inline -> Inline
g (Strong x) = Span def x
g (Emph x) = Span def x
g a = a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment