Skip to content

arxiv-vanity/pandoc

 
 

Repository files navigation

andreas' pandoc fork

work in progress....

Continuous compilation

./docker-watch-build.sh

Then you can add the pandoc binary to another container with

export PANDOC_BIN=/path/to/pandoc/.stack-work/install/x86_64-linux/lts-8.16/8.0.2/bin/pandoc
docker run --volumes $PANDOC_BIN:/bin/pandoc my-other-image

This will expose the /pandoc directory in the other container.

Development

Haskell resources

Haskell is hard. I skimmed through Learn You a Haskell and Real World Haskell. The parsing chapter from Write You a Haskell is good too for the stuff we're doing.

Hacking

Follow the "quick stack method" to install Stack and build Pandoc.

Emacs has Intero (here is a quick intro). C-l to send buffer to the GHCi REPL.

Without Emacs, you can still have a decent environment. Start GHCi with

$ stack ghci "--docker-run-args=--interactive=true --tty=false" --no-build --no-load pandoc

then load files with

Prelude> :load src/Text/Pandoc/Readers/LaTeX.hs

Most of the coding will be done on that particular src/Text/Pandoc/Readers/LaTeX.hs file. But you'll backtrack up through the source tree, and maybe also out to pandoc-types, especially the Text/Pandoc/Builder.hs and Text/Pandoc/Definition.hs files.

When you've loaded in src/Text/Pandoc/Readers/LaTeX.hs, you can run the parser from GHCi:

λ import Text.Pandoc.Class

λ let options = def{ readerExtensions = extensionsFromList [Ext_raw_tex, Ext_latex_macros], readerInputSources = ["foo.tex"] }

λ runIO $ runParserT parseLaTeX def{ sOptions = options } "source" (tokenize $ T.pack "hello \\emph{world}")
Right (Right (Pandoc (Meta {unMeta = fromList []}) [Para [Str "hello",Space,Emph [Str "world"]]]))

You can run specific parts of the parser

λ runIO $ runParserT parseAligns def{ sOptions = options } "source" (tokenize $ T.pack "{llrr}")
Right (Right [AlignLeft,AlignLeft,AlignRight,AlignRight])

Notice how we have to pack the strings to text with T.pack. I think that's avoided in LaTeX.hs with the {-# LANGUAGE OverloadedStrings #-} thing at the top.

On the REPL you can say :i to find out the type and source file of a thing (:t will give you just the type definition):

λ :i keyval
keyval :: PandocMonad m => LP m (String, String)
    -- Defined at /Users/andreasj/src/pandoc/src/Text/Pandoc/Readers/LaTeX.hs:727:1

λ :t (*>)
(*>) :: Applicative f => f a -> f b -> f b

You can't get Haddock docstrings on the REPL yet afaict, but Hoogle is pretty fast and smart:

About

[Archived - arXiv Vanity no longer uses Pandoc]

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Haskell 91.6%
  • HTML 5.1%
  • Lua 1.3%
  • Roff 1.3%
  • CSS 0.2%
  • Shell 0.2%
  • Other 0.3%