pandoc 2.9.2 → 2.9.2.1
raw patch · 210 files changed
+1853/−1831 lines, 210 filesdep +base-nopreludedep −basedep ~jira-wiki-markupPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: base-noprelude
Dependencies removed: base
Dependency ranges changed: jira-wiki-markup
API changes (from Hackage documentation)
- Text.Pandoc.Class: instance (Control.Monad.Trans.Class.MonadTrans t, Text.Pandoc.Class.PandocMonad m, GHC.Base.Functor (t m), Control.Monad.Error.Class.MonadError Text.Pandoc.Error.PandocError (t m), GHC.Base.Monad (t m), GHC.Base.Applicative (t m)) => Text.Pandoc.Class.PandocMonad (t m)
- Text.Pandoc.Class: instance Control.Monad.Error.Class.MonadError Text.Pandoc.Error.PandocError Text.Pandoc.Class.PandocIO
- Text.Pandoc.Class: instance Control.Monad.Error.Class.MonadError Text.Pandoc.Error.PandocError Text.Pandoc.Class.PandocPure
- Text.Pandoc.Class: instance Control.Monad.IO.Class.MonadIO Text.Pandoc.Class.PandocIO
- Text.Pandoc.Class: instance Data.Default.Class.Default Text.Pandoc.Class.CommonState
- Text.Pandoc.Class: instance Data.Default.Class.Default Text.Pandoc.Class.PureState
- Text.Pandoc.Class: instance GHC.Base.Applicative Text.Pandoc.Class.PandocIO
- Text.Pandoc.Class: instance GHC.Base.Applicative Text.Pandoc.Class.PandocPure
- Text.Pandoc.Class: instance GHC.Base.Functor Text.Pandoc.Class.PandocIO
- Text.Pandoc.Class: instance GHC.Base.Functor Text.Pandoc.Class.PandocPure
- Text.Pandoc.Class: instance GHC.Base.Monad Text.Pandoc.Class.PandocIO
- Text.Pandoc.Class: instance GHC.Base.Monad Text.Pandoc.Class.PandocPure
- Text.Pandoc.Class: instance GHC.Base.Monoid Text.Pandoc.Class.FileTree
- Text.Pandoc.Class: instance GHC.Base.Semigroup Text.Pandoc.Class.FileTree
- Text.Pandoc.Class: instance Text.Pandoc.Class.PandocMonad Text.Pandoc.Class.PandocIO
- Text.Pandoc.Class: instance Text.Pandoc.Class.PandocMonad Text.Pandoc.Class.PandocPure
- Text.Pandoc.Class: instance Text.Pandoc.Class.PandocMonad m => Text.Pandoc.Class.PandocMonad (Text.Parsec.Prim.ParsecT s st m)
- Text.Pandoc.Readers.HTML: instance Text.Pandoc.Class.PandocMonad m => Text.Pandoc.Parsing.HasQuoteContext Text.Pandoc.Readers.HTML.HTMLState (Control.Monad.Trans.Reader.ReaderT Text.Pandoc.Readers.HTML.HTMLLocal m)
- Text.Pandoc.Templates: instance Text.Pandoc.Class.PandocMonad m => Text.DocTemplates.Internal.TemplateMonad (Text.Pandoc.Templates.WithDefaultPartials m)
- Text.Pandoc.Templates: instance Text.Pandoc.Class.PandocMonad m => Text.DocTemplates.Internal.TemplateMonad (Text.Pandoc.Templates.WithPartials m)
+ Text.Pandoc.Class: makeCanonical :: FilePath -> FilePath
+ Text.Pandoc.Readers.HTML: instance Text.Pandoc.Class.PandocMonad.PandocMonad m => Text.Pandoc.Parsing.HasQuoteContext Text.Pandoc.Readers.HTML.HTMLState (Control.Monad.Trans.Reader.ReaderT Text.Pandoc.Readers.HTML.HTMLLocal m)
+ Text.Pandoc.Templates: instance Text.Pandoc.Class.PandocMonad.PandocMonad m => Text.DocTemplates.Internal.TemplateMonad (Text.Pandoc.Templates.WithDefaultPartials m)
+ Text.Pandoc.Templates: instance Text.Pandoc.Class.PandocMonad.PandocMonad m => Text.DocTemplates.Internal.TemplateMonad (Text.Pandoc.Templates.WithPartials m)
Files
- COPYRIGHT +31/−15
- MANUAL.txt +8/−5
- README.md +2/−2
- changelog.md +102/−6
- man/pandoc.1 +8/−4
- pandoc.cabal +38/−44
- pandoc.hs +1/−1
- prelude/Prelude.hs +0/−2
- src/Text/Pandoc.hs +1/−1
- src/Text/Pandoc/App.hs +3/−4
- src/Text/Pandoc/App/CommandLineOptions.hs +4/−6
- src/Text/Pandoc/App/FormatHeuristics.hs +1/−3
- src/Text/Pandoc/App/Opt.hs +1/−3
- src/Text/Pandoc/App/OutputSettings.hs +1/−3
- src/Text/Pandoc/Asciify.hs +1/−3
- src/Text/Pandoc/BCP47.hs +1/−3
- src/Text/Pandoc/CSS.hs +1/−3
- src/Text/Pandoc/CSV.hs +1/−3
- src/Text/Pandoc/Class.hs +29/−1068
- src/Text/Pandoc/Class/CommonState.hs +80/−0
- src/Text/Pandoc/Class/PandocIO.hs +218/−0
- src/Text/Pandoc/Class/PandocMonad.hs +699/−0
- src/Text/Pandoc/Class/PandocPure.hs +218/−0
- src/Text/Pandoc/Data.hs +1/−3
- src/Text/Pandoc/Emoji.hs +0/−2
- src/Text/Pandoc/Error.hs +1/−3
- src/Text/Pandoc/Extensions.hs +1/−3
- src/Text/Pandoc/Filter.hs +3/−4
- src/Text/Pandoc/Filter/JSON.hs +2/−4
- src/Text/Pandoc/Filter/Lua.hs +2/−4
- src/Text/Pandoc/Filter/Path.hs +2/−4
- src/Text/Pandoc/Highlighting.hs +1/−3
- src/Text/Pandoc/Image.hs +0/−2
- src/Text/Pandoc/ImageSize.hs +1/−3
- src/Text/Pandoc/Logging.hs +1/−3
- src/Text/Pandoc/Lua.hs +1/−2
- src/Text/Pandoc/Lua/Filter.hs +0/−2
- src/Text/Pandoc/Lua/Global.hs +2/−4
- src/Text/Pandoc/Lua/Init.hs +4/−5
- src/Text/Pandoc/Lua/Marshaling.hs +2/−2
- src/Text/Pandoc/Lua/Marshaling/AST.hs +2/−6
- src/Text/Pandoc/Lua/Marshaling/AnyValue.hs +1/−3
- src/Text/Pandoc/Lua/Marshaling/CommonState.hs +2/−4
- src/Text/Pandoc/Lua/Marshaling/Context.hs +2/−6
- src/Text/Pandoc/Lua/Marshaling/List.hs +1/−3
- src/Text/Pandoc/Lua/Marshaling/MediaBag.hs +2/−4
- src/Text/Pandoc/Lua/Marshaling/ReaderOptions.hs +4/−7
- src/Text/Pandoc/Lua/Marshaling/Version.hs +1/−3
- src/Text/Pandoc/Lua/Module/MediaBag.hs +4/−5
- src/Text/Pandoc/Lua/Module/Pandoc.hs +2/−4
- src/Text/Pandoc/Lua/Module/System.hs +1/−2
- src/Text/Pandoc/Lua/Module/Types.hs +1/−2
- src/Text/Pandoc/Lua/Module/Utils.hs +3/−4
- src/Text/Pandoc/Lua/Packages.hs +3/−4
- src/Text/Pandoc/Lua/Util.hs +4/−5
- src/Text/Pandoc/Lua/Walk.hs +2/−4
- src/Text/Pandoc/MIME.hs +1/−3
- src/Text/Pandoc/MediaBag.hs +1/−3
- src/Text/Pandoc/Options.hs +1/−3
- src/Text/Pandoc/PDF.hs +6/−8
- src/Text/Pandoc/Parsing.hs +2/−4
- src/Text/Pandoc/Process.hs +1/−3
- src/Text/Pandoc/Readers.hs +1/−3
- src/Text/Pandoc/Readers/CSV.hs +1/−3
- src/Text/Pandoc/Readers/CommonMark.hs +2/−4
- src/Text/Pandoc/Readers/Creole.hs +1/−3
- src/Text/Pandoc/Readers/DocBook.hs +2/−4
- src/Text/Pandoc/Readers/Docx.hs +3/−5
- src/Text/Pandoc/Readers/Docx/Combine.hs +2/−4
- src/Text/Pandoc/Readers/Docx/Fields.hs +1/−3
- src/Text/Pandoc/Readers/Docx/Lists.hs +1/−3
- src/Text/Pandoc/Readers/Docx/Parse.hs +1/−3
- src/Text/Pandoc/Readers/Docx/Parse/Styles.hs +1/−3
- src/Text/Pandoc/Readers/Docx/Util.hs +2/−4
- src/Text/Pandoc/Readers/DokuWiki.hs +2/−4
- src/Text/Pandoc/Readers/EPUB.hs +2/−4
- src/Text/Pandoc/Readers/FB2.hs +2/−3
- src/Text/Pandoc/Readers/HTML.hs +2/−4
- src/Text/Pandoc/Readers/Haddock.hs +1/−3
- src/Text/Pandoc/Readers/Ipynb.hs +2/−4
- src/Text/Pandoc/Readers/JATS.hs +2/−4
- src/Text/Pandoc/Readers/Jira.hs +4/−4
- src/Text/Pandoc/Readers/LaTeX.hs +6/−7
- src/Text/Pandoc/Readers/LaTeX/Lang.hs +1/−3
- src/Text/Pandoc/Readers/LaTeX/Parsing.hs +2/−4
- src/Text/Pandoc/Readers/LaTeX/Types.hs +1/−3
- src/Text/Pandoc/Readers/Man.hs +2/−3
- src/Text/Pandoc/Readers/Markdown.hs +3/−5
- src/Text/Pandoc/Readers/MediaWiki.hs +2/−4
- src/Text/Pandoc/Readers/Metadata.hs +2/−4
- src/Text/Pandoc/Readers/Muse.hs +2/−4
- src/Text/Pandoc/Readers/Native.hs +2/−4
- src/Text/Pandoc/Readers/OPML.hs +2/−4
- src/Text/Pandoc/Readers/Odt.hs +2/−4
- src/Text/Pandoc/Readers/Odt/Arrows/State.hs +0/−2
- src/Text/Pandoc/Readers/Odt/Arrows/Utils.hs +0/−2
- src/Text/Pandoc/Readers/Odt/ContentReader.hs +0/−2
- src/Text/Pandoc/Readers/Odt/Generic/Fallible.hs +0/−2
- src/Text/Pandoc/Readers/Odt/Generic/Namespaces.hs +0/−2
- src/Text/Pandoc/Readers/Odt/Generic/SetMap.hs +0/−2
- src/Text/Pandoc/Readers/Odt/Generic/Utils.hs +0/−2
- src/Text/Pandoc/Readers/Odt/Generic/XMLConverter.hs +0/−2
- src/Text/Pandoc/Readers/Odt/Namespaces.hs +0/−2
- src/Text/Pandoc/Readers/Odt/StyleReader.hs +0/−2
- src/Text/Pandoc/Readers/Org.hs +2/−4
- src/Text/Pandoc/Readers/Org/BlockStarts.hs +1/−3
- src/Text/Pandoc/Readers/Org/Blocks.hs +2/−4
- src/Text/Pandoc/Readers/Org/DocumentTree.hs +2/−4
- src/Text/Pandoc/Readers/Org/ExportSettings.hs +2/−4
- src/Text/Pandoc/Readers/Org/Inlines.hs +2/−4
- src/Text/Pandoc/Readers/Org/Meta.hs +2/−4
- src/Text/Pandoc/Readers/Org/ParserState.hs +1/−3
- src/Text/Pandoc/Readers/Org/Parsing.hs +1/−3
- src/Text/Pandoc/Readers/Org/Shared.hs +1/−3
- src/Text/Pandoc/Readers/RST.hs +2/−4
- src/Text/Pandoc/Readers/Roff.hs +4/−5
- src/Text/Pandoc/Readers/TWiki.hs +1/−3
- src/Text/Pandoc/Readers/Textile.hs +2/−4
- src/Text/Pandoc/Readers/TikiWiki.hs +2/−3
- src/Text/Pandoc/Readers/Txt2Tags.hs +2/−4
- src/Text/Pandoc/Readers/Vimwiki.hs +2/−4
- src/Text/Pandoc/RoffChar.hs +1/−3
- src/Text/Pandoc/SelfContained.hs +3/−5
- src/Text/Pandoc/Shared.hs +1/−3
- src/Text/Pandoc/Slides.hs +1/−3
- src/Text/Pandoc/Templates.hs +4/−4
- src/Text/Pandoc/Translations.hs +1/−3
- src/Text/Pandoc/UTF8.hs +1/−1
- src/Text/Pandoc/UUID.hs +1/−3
- src/Text/Pandoc/Writers.hs +1/−3
- src/Text/Pandoc/Writers/AsciiDoc.hs +2/−5
- src/Text/Pandoc/Writers/CommonMark.hs +2/−4
- src/Text/Pandoc/Writers/ConTeXt.hs +2/−4
- src/Text/Pandoc/Writers/Custom.hs +2/−4
- src/Text/Pandoc/Writers/Docbook.hs +2/−4
- src/Text/Pandoc/Writers/Docx.hs +3/−5
- src/Text/Pandoc/Writers/Docx/StyleMap.hs +2/−4
- src/Text/Pandoc/Writers/DokuWiki.hs +2/−4
- src/Text/Pandoc/Writers/EPUB.hs +6/−6
- src/Text/Pandoc/Writers/FB2.hs +3/−5
- src/Text/Pandoc/Writers/HTML.hs +3/−5
- src/Text/Pandoc/Writers/Haddock.hs +1/−3
- src/Text/Pandoc/Writers/ICML.hs +3/−6
- src/Text/Pandoc/Writers/Ipynb.hs +2/−4
- src/Text/Pandoc/Writers/JATS.hs +1/−3
- src/Text/Pandoc/Writers/Jira.hs +2/−4
- src/Text/Pandoc/Writers/LaTeX.hs +2/−4
- src/Text/Pandoc/Writers/Man.hs +2/−4
- src/Text/Pandoc/Writers/Markdown.hs +2/−4
- src/Text/Pandoc/Writers/Math.hs +1/−3
- src/Text/Pandoc/Writers/MediaWiki.hs +2/−4
- src/Text/Pandoc/Writers/Ms.hs +7/−8
- src/Text/Pandoc/Writers/Muse.hs +2/−4
- src/Text/Pandoc/Writers/Native.hs +2/−4
- src/Text/Pandoc/Writers/ODT.hs +3/−5
- src/Text/Pandoc/Writers/OOXML.hs +2/−4
- src/Text/Pandoc/Writers/OPML.hs +2/−4
- src/Text/Pandoc/Writers/OpenDocument.hs +3/−5
- src/Text/Pandoc/Writers/Org.hs +3/−5
- src/Text/Pandoc/Writers/Powerpoint.hs +2/−4
- src/Text/Pandoc/Writers/Powerpoint/Output.hs +3/−5
- src/Text/Pandoc/Writers/Powerpoint/Presentation.hs +1/−3
- src/Text/Pandoc/Writers/RST.hs +2/−4
- src/Text/Pandoc/Writers/RTF.hs +3/−5
- src/Text/Pandoc/Writers/Roff.hs +2/−4
- src/Text/Pandoc/Writers/Shared.hs +1/−3
- src/Text/Pandoc/Writers/TEI.hs +2/−4
- src/Text/Pandoc/Writers/Texinfo.hs +2/−4
- src/Text/Pandoc/Writers/Textile.hs +2/−4
- src/Text/Pandoc/Writers/XWiki.hs +1/−3
- src/Text/Pandoc/Writers/ZimWiki.hs +3/−4
- src/Text/Pandoc/XML.hs +8/−3
- stack.yaml +1/−1
- test/Tests/Command.hs +1/−1
- test/Tests/Helpers.hs +1/−1
- test/Tests/Lua.hs +1/−1
- test/Tests/Lua/Module.hs +1/−1
- test/Tests/Old.hs +1/−1
- test/Tests/Readers/Creole.hs +1/−1
- test/Tests/Readers/Docx.hs +1/−1
- test/Tests/Readers/DokuWiki.hs +1/−1
- test/Tests/Readers/EPUB.hs +1/−1
- test/Tests/Readers/FB2.hs +2/−2
- test/Tests/Readers/HTML.hs +1/−1
- test/Tests/Readers/Jira.hs +14/−1
- test/Tests/Readers/LaTeX.hs +1/−1
- test/Tests/Readers/Man.hs +2/−2
- test/Tests/Readers/Markdown.hs +1/−1
- test/Tests/Readers/Muse.hs +1/−1
- test/Tests/Readers/Odt.hs +1/−1
- test/Tests/Readers/Org.hs +1/−1
- test/Tests/Readers/Org/Block.hs +1/−1
- test/Tests/Readers/Org/Block/CodeBlock.hs +1/−1
- test/Tests/Readers/Org/Block/Figure.hs +1/−1
- test/Tests/Readers/Org/Block/Header.hs +1/−1
- test/Tests/Readers/Org/Block/List.hs +1/−1
- test/Tests/Readers/Org/Block/Table.hs +1/−1
- test/Tests/Readers/Org/Directive.hs +1/−1
- test/Tests/Readers/Org/Inline.hs +1/−1
- test/Tests/Readers/Org/Inline/Citation.hs +1/−1
- test/Tests/Readers/Org/Inline/Note.hs +1/−1
- test/Tests/Readers/Org/Inline/Smart.hs +1/−1
- test/Tests/Readers/Org/Meta.hs +1/−1
- test/Tests/Readers/Org/Shared.hs +1/−1
- test/Tests/Readers/RST.hs +1/−1
- test/Tests/Readers/Txt2Tags.hs +1/−1
- test/Tests/Shared.hs +1/−1
- test/writer.ms +53/−53
- trypandoc/index.html +15/−7
- trypandoc/trypandoc.hs +5/−2
COPYRIGHT view
@@ -1,5 +1,5 @@ Pandoc-Copyright (C) 2006-2019 John MacFarlane <jgm at berkeley dot edu>+Copyright (C) 2006-2020 John MacFarlane <jgm at berkeley dot edu> With the exceptions noted below, this code is released under the [GPL], version 2 or later:@@ -37,7 +37,7 @@ Text.Pandoc.Builder, Text.Pandoc.Generics, Text.Pandoc.JSON, Text.Pandoc.Walk) are licensed under the BSD 3-clause license: -Copyright (c) 2006-2019, John MacFarlane+Copyright (c) 2006-2020, John MacFarlane All rights reserved. @@ -73,29 +73,29 @@ GPL (v2 or higher, same as pandoc) or (at your option) the BSD 3-clause license. -Copyright (c) 2014--2019, John MacFarlane+Copyright (c) 2014--2020, John MacFarlane ---------------------------------------------------------------------- src/Text/Pandoc/Writers/Muse.hs-Copyright (C) 2017-2019 Alexander Krotov+Copyright (C) 2017-2020 Alexander Krotov Released under the GNU General Public License version 2 or later. ---------------------------------------------------------------------- src/Text/Pandoc/Writers/Texinfo.hs-Copyright (C) 2008-2019 John MacFarlane and Peter Wang+Copyright (C) 2008-2020 John MacFarlane and Peter Wang Released under the GNU General Public License version 2 or later. ---------------------------------------------------------------------- src/Text/Pandoc/Writers/OpenDocument.hs-Copyright (C) 2008-2019 Andrea Rossato and John MacFarlane+Copyright (C) 2008-2020 Andrea Rossato and John MacFarlane Released under the GNU General Public License version 2 or later. ---------------------------------------------------------------------- src/Text/Pandoc/Writers/Org.hs-Copyright (C) 2010-2019 Puneeth Chaganti, John MacFarlane, and+Copyright (C) 2010-2020 Puneeth Chaganti, John MacFarlane, and Albert Krewinkel Released under the GNU General Public License version 2 or later.@@ -109,13 +109,13 @@ ---------------------------------------------------------------------- src/Text/Pandoc/Readers/Docx.hs src/Text/Pandoc/Readers/Docx/*-Copyright (C) 2014-2019 Jesse Rosenthal+Copyright (C) 2014-2020 Jesse Rosenthal Released under the GNU General Public License version 2 or later. ---------------------------------------------------------------------- src/Text/Pandoc/Readers/Textile.hs-Copyright (C) 2010-2019 Paul Rivier and John MacFarlane+Copyright (C) 2010-2020 Paul Rivier and John MacFarlane Released under the GNU General Public License version 2 or later. @@ -133,7 +133,7 @@ ---------------------------------------------------------------------- src/Text/Pandoc/Readers/EPUB.hs-Copyright (C) 2014-2018 Matthew Pickering+Copyright (C) 2014-2020 Matthew Pickering and John MacFarlane Released under the GNU General Public License version 2 or later. @@ -141,19 +141,35 @@ src/Text/Pandoc/Readers/Org.hs src/Text/Pandoc/Readers/Org/* test/Tests/Readers/Org/*-Copyright (C) 2014-2019 Albert Krewinkel+Copyright (C) 2014-2020 Albert Krewinkel Released under the GNU General Public License version 2 or later. ----------------------------------------------------------------------+src/Text/Pandoc/Lua.hs+src/Text/Pandoc/Lua/*+test/lua/*+Copyright (C) 2017--2020 Albert Krewinkel and John MacFarlane++Released under the GNU General Public License version 2 or later.++----------------------------------------------------------------------+src/Text/Pandoc/Readers/Jira.hs+src/Text/Pandoc/Writers/Jira.hs+test/Tests/Readers/Jira.hs+Copyright (C) 2019--2020 Albert Krewinkel++Released under the GNU General Public License version 2 or later.++---------------------------------------------------------------------- src/Text/Pandoc/Readers/FB2.hs-Copyright (C) 2018 Alexander Krotov+Copyright (C) 2018--2019 Alexander Krotov Released under the GNU General Public License version 2 or later. ---------------------------------------------------------------------- data/pandoc.lua-Copyright (C) 2017-2019 Albert Krewinkel+Copyright (C) 2017-2020 Albert Krewinkel Released under the GNU General Public License version 2 or later. @@ -167,7 +183,7 @@ ------------------------------------------------------------------------ Pandoc embeds a lua interpreter (via hslua). -Copyright © 1994–2017 Lua.org, PUC-Rio.+Copyright © 1994–2019 Lua.org, PUC-Rio. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the@@ -189,7 +205,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------The template pandoc.jats is Copyright 2013--15 Martin Fenner,+The template pandoc.jats is Copyright 2013--2015 Martin Fenner, released under GPL version 2 or later. The file data/jats.csl is derived from a csl file by Martin Fenner,
MANUAL.txt view
@@ -1,7 +1,7 @@ --- title: Pandoc User's Guide author: John MacFarlane-date: February 15, 2020+date: March 23, 2020 --- # Synopsis@@ -4019,9 +4019,12 @@ (However, if the `markdown_strict` format is used, the standard Markdown rule will be used.) -A backslash-escaped space is parsed as a nonbreaking space. It will-appear in TeX output as `~` and in HTML and XML as `\ ` or-`\ `.+A backslash-escaped space is parsed as a nonbreaking space. In TeX output,+it will appear as `~`. In HTML and XML output, it will appear as a+literal unicode nonbreaking space character (note that it will thus+actually look "invisible" in the generated HTML source; you can still+use the `--ascii` command-line option to make it appear as an explicit+entity). A backslash-escaped newline (i.e. a backslash occurring at the end of a line) is parsed as a hard line break. It will appear in TeX output as@@ -5891,7 +5894,7 @@ # Authors -Copyright 2006--2019 John MacFarlane (jgm@berkeley.edu). Released+Copyright 2006--2020 John MacFarlane (jgm@berkeley.edu). Released under the [GPL], version 2 or greater. This software carries no warranty of any kind. (See COPYRIGHT for full copyright and warranty notices.) For a full list of contributors, see the file
README.md view
@@ -192,7 +192,7 @@ input or output format requires only adding a reader or writer. Users can also run custom pandoc filters to modify the intermediate AST (see the documentation for [filters](https://pandoc.org/filters.html) and-[lua filters](https://pandoc.org/lua-filters.html)).+[Lua filters](https://pandoc.org/lua-filters.html)). Because pandoc’s intermediate representation of a document is less expressive than many of the formats it converts between, one should not@@ -225,7 +225,7 @@ ## License -© 2006-2018 John MacFarlane (jgm@berkeley.edu). Released under the+© 2006-2020 John MacFarlane (jgm@berkeley.edu). Released under the [GPL](http://www.gnu.org/copyleft/gpl.html "GNU General Public License"), version 2 or greater. This software carries no warranty of any kind. (See COPYRIGHT for full copyright and warranty notices.)
changelog.md view
@@ -1,5 +1,104 @@ # Revision history for pandoc +## pandoc 2.9.2.1 (2020-03-23)++ * Markdown reader: Fix table alignment when heading begins with t (#6153).+ Due to a typo (`t` instead of `\t`) we were center aligning column+ headings that begin with a lowercase `t`!++ * Text.Pandoc.Readers.Roff:++ + Fix parsing of `\.` in man/ms readers (#6175).+ Previously due to a typo it was being parsed as `` ` ``.+ + Fix parsing of `\'` in man/ms readers (#6175). It was being parsed+ as a backtick.++ * Jira reader (Albert Krewinkel):++ + Fix parsing of tables without preceding blankline (#6198).+ A bug was fixed which caused faulty parsing if a table was not+ preceded by a newline and the first table cell had no space+ after the initial `|` characters.+ + Fix parsing of strikeout, emphasis (#6196). A bug was fixed which+ caused non-emphasized text containing digits and/or non-special+ symbols (like dots) to sometimes be parsed incorrectly.+ + Support colored inline text, indented lists (#6183, #6184).++ * Ms writer:++ + Fix definition lists so indent even when paragraph indent is+ set to 0 (as is the default). Also ensure indent for display math+ that falls back to TeX.+ + Use `.QS/.QE` instead of `.RS/.RE` for block quotes.++ * EPUB writer: fix regression on detection of front/back/bodymatter+ (#6170). This bug caused sections with epub:type `dedication` to be+ misplaced in bodymatter instead of frontmatter as specified+ in the manual. The same problem would affect other epub:types.+ The pattern matching needed to be changed with the use of+ `makeSection`.++ * AsciiDoc writer: remove redundant `otherwise` guard in+ `inlineToAsciiDoc` (#6146, Ryan Scott).++ * Text.Pandoc.Class:++ + Fix missing import when data files are not embedded (Albert Krewinkel).+ + Subdivide Text.Pandoc.Class into small unexported modules+ and ensure that all functions have Haddock documentation (#6106,+ Albert Krewinkel).+ + Finer grained imports of Text.Pandoc.Class submodules (#6203, Albert+ Krewinkel).++ * Text.Pandoc.XML: Add to list of HTML5 attributes:+ `allow`, `autocapitalize`, `decoding`, `enterkeyhint`,+ `imagesizes`, `imagesrcset`, `loading`.++ * Use implicit Prelude (#6187, Albert Krewinkel).+ The previous behavior was introduced as a fix for #4464. It seems that+ this change alone did not fix the issue, and `stack ghci` and `cabal+ repl` only work with GHC 8.4.1 or newer, as no custom Prelude is loaded+ for these versions. Given this, it seems cleaner to revert to the+ implicit Prelude.++ * Always use custom prelude (#6187, Albert Krewinkel).+ Previously, the custom prelude was used only with older GHC versions, as+ a workaround for problems with ghci. The ghci problems are resolved by+ replacing package `base` with `base-noprelude`, allowing for consistent+ use of the custom prelude across all GHC versions.++ * Remove outdated checks for no longer supported base versions+ (Albert Krewinkel).++ * PDF via wkhtmltopdf: put user-specified options last (#6171).+ Certain options (e.g. `cover`) need to come after flags on+ the command line.++ * Text.Pandoc.App: set resource path at the beginning so it can affect+ things like include-in-header (#5982).++ * Change macOS release candidate CI process so that notarized+ packages can be produced (#6169).++ * Make MANUAL more explicit about nonbreaking space handling by+ `all_symbols_escapable` (#6154, Fabien Schurter).++ * trypandoc (Mike Tzou):++ + Add checkbox for standalone option (#6189).+ + Use strict mode for JavaScript code (#6188).+ + Fetch resources over https (#6188).+ + Remove unnecessary attributes on style, script elements (#6188).++ * Use details tag to make GitHub releases changelog collapsible.++ * Update filter code in doc/filters.md so it works with latest pandoc+ (#6185).++ * linux/Dockerfile: upgrade to alpine 3.11 (#6180, Albert Krewinkel).+ This is used to build the static linux binaries.++ ## pandoc 2.9.2 (2020-02-15) * Add `csv` as an input format (#6100). The CSV table is converted into a@@ -107,12 +206,9 @@ * Add Text.Pandoc.Image with unexported svgToPng. - * Moved html5Attributes, html4Attributes, rdfaAttributes- from T.P.Writers.HTML (where they were unexported) to- T.P.XML (where they are now exported).- [API change: new exported functions]- This allows these sets to be used elsewhere, e.g.- in the HTML reader.+ * Text.Pandoc.XML: Export `html5Attributes`, `html4Attributes`,+ `rdfaAttributes` (formerly unexported in Text.Pandoc.Writers.HTML).+ [API change] * Text.Pandoc.Shared: Export a new function `findM` (#6125, Joseph C. Sible).
man/pandoc.1 view
@@ -1,7 +1,7 @@ .\"t .\" Automatically generated by Pandoc 2.9.2 .\"-.TH "Pandoc User\[aq]s Guide" "" "February 15, 2020" "pandoc 2.9.2" ""+.TH "Pandoc User\[aq]s Guide" "" "March 23, 2020" "pandoc 2.9.2.1" "" .hy .SH NAME pandoc - general markup converter@@ -4713,8 +4713,12 @@ Markdown rule will be used.) .PP A backslash-escaped space is parsed as a nonbreaking space.-It will appear in TeX output as \f[C]\[ti]\f[R] and in HTML and XML as-\f[C]\[rs] \f[R] or \f[C]\[rs] \f[R].+In TeX output, it will appear as \f[C]\[ti]\f[R].+In HTML and XML output, it will appear as a literal unicode nonbreaking+space character (note that it will thus actually look+\[dq]invisible\[dq] in the generated HTML source; you can still use the+\f[C]--ascii\f[R] command-line option to make it appear as an explicit+entity). .PP A backslash-escaped newline (i.e. a backslash occurring at the end of a line) is parsed as a hard line@@ -7093,7 +7097,7 @@ sanitizer. .SH AUTHORS .PP-Copyright 2006--2019 John MacFarlane (jgm\[at]berkeley.edu).+Copyright 2006--2020 John MacFarlane (jgm\[at]berkeley.edu). Released under the GPL, version 2 or greater. This software carries no warranty of any kind. (See COPYRIGHT for full copyright and warranty notices.) For a full list
pandoc.cabal view
@@ -1,10 +1,10 @@ name: pandoc-version: 2.9.2+version: 2.9.2.1 cabal-version: 2.0 build-type: Simple license: GPL-2 license-file: COPYING.md-copyright: (c) 2006-2019 John MacFarlane+copyright: (c) 2006-2020 John MacFarlane author: John MacFarlane <jgm@berkeley.edu> maintainer: John MacFarlane <jgm@berkeley.edu> bug-reports: https://github.com/jgm/pandoc/issues@@ -377,7 +377,8 @@ Default: False library- build-depends: base >= 4.9 && < 5,+ build-depends: base-noprelude >= 4.9 && < 5,+ base-compat >= 0.9, syb >= 0.1 && < 0.8, containers >= 0.4.2.1 && < 0.7, unordered-containers >= 0.2 && < 0.3,@@ -411,7 +412,7 @@ blaze-html >= 0.9 && < 0.10, blaze-markup >= 0.8 && < 0.9, vector >= 0.10 && < 0.13,- jira-wiki-markup >= 1.0 && < 1.1,+ jira-wiki-markup >= 1.1.3 && < 1.2, hslua >= 1.0.1 && < 1.1, hslua-module-system >= 0.2 && < 0.3, hslua-module-text >= 0.2 && < 0.3,@@ -440,10 +441,6 @@ build-depends: basement >= 0.0.10, foundation >= 0.0.23 -- basement 0.0.9 won't build on 32-bit windows.- if impl(ghc < 8.4)- hs-source-dirs: prelude- other-modules: Prelude- build-depends: base-compat >= 0.9 if os(windows) cpp-options: -D_WINDOWS else@@ -471,7 +468,8 @@ default-language: Haskell2010 other-extensions: NoImplicitPrelude- hs-source-dirs: src+ hs-source-dirs: src,+ prelude exposed-modules: Text.Pandoc, Text.Pandoc.App,@@ -565,10 +563,15 @@ Text.Pandoc.ImageSize, Text.Pandoc.BCP47, Text.Pandoc.Class- other-modules: Text.Pandoc.App.CommandLineOptions,+ other-modules: Prelude,+ Text.Pandoc.App.CommandLineOptions, Text.Pandoc.App.FormatHeuristics, Text.Pandoc.App.Opt, Text.Pandoc.App.OutputSettings,+ Text.Pandoc.Class.CommonState,+ Text.Pandoc.Class.PandocMonad,+ Text.Pandoc.Class.PandocIO,+ Text.Pandoc.Class.PandocPure, Text.Pandoc.Filter.JSON, Text.Pandoc.Filter.Lua, Text.Pandoc.Filter.Path,@@ -638,19 +641,19 @@ buildable: True executable pandoc- build-depends: pandoc, base >= 4.8 && < 5- if impl(ghc < 8.4)- hs-source-dirs: prelude- other-modules: Prelude- build-depends: base-compat >= 0.9+ build-depends: pandoc,+ base-noprelude >= 4.8 && < 5,+ base-compat >= 0.9 if flag(static) ld-options: -static default-language: Haskell2010 other-extensions: NoImplicitPrelude hs-source-dirs: .+ prelude main-is: pandoc.hs buildable: True- other-modules: Paths_pandoc+ other-modules: Paths_pandoc,+ Prelude ghc-options: -rtsopts -with-rtsopts=-K16m -threaded -Wall -fno-warn-unused-do-bind -Wincomplete-record-updates@@ -665,19 +668,16 @@ executable trypandoc main-is: trypandoc.hs- hs-source-dirs: trypandoc+ hs-source-dirs: trypandoc, prelude default-language: Haskell2010 other-extensions: NoImplicitPrelude+ other-modules: Prelude if flag(trypandoc)- build-depends: base, aeson, pandoc,+ build-depends: base-noprelude, base-compat >= 0.9, aeson, pandoc, text, wai-extra, wai >= 0.3, http-types buildable: True else buildable: False- if impl(ghc < 8.4)- hs-source-dirs: prelude- other-modules: Prelude- build-depends: base-compat >= 0.9 ghc-options: -rtsopts -with-rtsopts=-K16m -threaded -Wall -fno-warn-unused-do-bind -Wincomplete-record-updates@@ -693,18 +693,16 @@ benchmark weigh-pandoc type: exitcode-stdio-1.0 main-is: weigh-pandoc.hs- hs-source-dirs: benchmark+ hs-source-dirs: benchmark,+ prelude build-depends: pandoc,- base >= 4.8 && < 5,+ base-noprelude >= 4.8 && < 5,+ base-compat >= 0.9, text, weigh >= 0.0 && < 0.1, mtl >= 2.2 && < 2.3- if impl(ghc < 8.4)- hs-source-dirs: prelude- other-modules: Prelude- build-depends: base-compat >= 0.9 default-language: Haskell2010- other-extensions: NoImplicitPrelude+ other-modules: Prelude ghc-options: -rtsopts -with-rtsopts=-K16m -threaded -Wall -fno-warn-unused-do-bind -Wincomplete-record-updates@@ -721,8 +719,10 @@ test-suite test-pandoc type: exitcode-stdio-1.0 main-is: test-pandoc.hs- hs-source-dirs: test- build-depends: base >= 4.8 && < 5,+ hs-source-dirs: test,+ prelude+ build-depends: base-noprelude >= 4.8 && < 5,+ base-compat >= 0.9, pandoc, pandoc-types >= 1.20 && < 1.21, mtl >= 2.2 && < 2.3,@@ -748,11 +748,8 @@ xml >= 1.3.12 && < 1.4, doctemplates >= 0.8 && < 0.9, Glob >= 0.7 && < 0.11- if impl(ghc < 8.4)- hs-source-dirs: prelude- other-modules: Prelude- build-depends: base-compat >= 0.9- other-modules: Tests.Old+ other-modules: Prelude+ Tests.Old Tests.Command Tests.Helpers Tests.Lua@@ -807,7 +804,6 @@ if os(windows) cpp-options: -D_WINDOWS default-language: Haskell2010- other-extensions: NoImplicitPrelude ghc-options: -rtsopts -with-rtsopts=-K16m -threaded -Wall -fno-warn-unused-do-bind -Wincomplete-record-updates@@ -824,19 +820,17 @@ benchmark benchmark-pandoc type: exitcode-stdio-1.0 main-is: benchmark-pandoc.hs- hs-source-dirs: benchmark+ hs-source-dirs: benchmark,+ prelude build-depends: pandoc, time, bytestring, containers,- base >= 4.8 && < 5,+ base-noprelude >= 4.8 && < 5,+ base-compat >= 0.9, text >= 1.1.1.0 && < 1.3, mtl >= 2.2 && < 2.3, criterion >= 1.0 && < 1.6- if impl(ghc < 8.4)- hs-source-dirs: prelude- other-modules: Prelude- build-depends: base-compat >= 0.9 default-language: Haskell2010- other-extensions: NoImplicitPrelude+ other-modules: Prelude ghc-options: -rtsopts -with-rtsopts=-K16m -threaded -Wall -fno-warn-unused-do-bind -Wincomplete-record-updates
pandoc.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE NoImplicitPrelude #-} {- | Module : Main- Copyright : Copyright (C) 2006-2018 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley@edu>
prelude/Prelude.hs view
@@ -1,6 +1,4 @@ {-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE PackageImports #-}-{-# LANGUAGE CPP #-} -- The intent is that this Prelude provide the API of -- the base 4.11 Prelude in a way that is portable for
src/Text/Pandoc.hs view
@@ -3,7 +3,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {- | Module : Text.Pandoc- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>
src/Text/Pandoc/App.hs view
@@ -1,10 +1,9 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE CPP #-} {-# LANGUAGE ScopedTypeVariables #-} {- | Module : Text.Pandoc.App- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley@edu>@@ -23,7 +22,6 @@ , options , applyFilters ) where-import Prelude import qualified Control.Exception as E import Control.Monad import Control.Monad.Trans@@ -125,6 +123,8 @@ runIO' $ do setUserDataDir datadir+ setResourcePath (optResourcePath opts)+ setInputFiles (fromMaybe ["-"] (optInputFiles opts)) setOutputFile (optOutputFile opts) @@ -268,7 +268,6 @@ writerName == "markdown_github") $ report $ Deprecated "markdown_github" "Use gfm instead." - setResourcePath (optResourcePath opts) mapM_ (uncurry setRequestHeader) (optRequestHeaders opts) doc <- sourceToDoc sources >>=
src/Text/Pandoc/App/CommandLineOptions.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE CPP #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TupleSections #-}@@ -6,7 +5,7 @@ {-# LANGUAGE FlexibleContexts #-} {- | Module : Text.Pandoc.App.CommandLineOptions- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley@edu>@@ -22,7 +21,6 @@ , lookupHighlightStyle , setVariable ) where-import Prelude import Control.Monad import Control.Monad.Trans import Control.Monad.Except (throwError)@@ -32,7 +30,7 @@ import Data.Char (toLower) import Data.List (intercalate, sort) #ifdef _WINDOWS-#if MIN_VERSION_base(4,12,0)+#if MIN_VERSION_base_noprelude(4,12,0) import Data.List (isPrefixOf) #endif #endif@@ -926,7 +924,7 @@ copyrightMessage :: String copyrightMessage = intercalate "\n" [- "Copyright (C) 2006-2019 John MacFarlane",+ "Copyright (C) 2006-2020 John MacFarlane", "Web: https://pandoc.org", "This is free software; see the source for copying conditions.", "There is no warranty, not even for merchantability or fitness",@@ -1030,7 +1028,7 @@ -- beginning with \\ to \\?\UNC\. -- See #5127. normalizePath :: FilePath -> FilePath #ifdef _WINDOWS-#if MIN_VERSION_base(4,12,0)+#if MIN_VERSION_base_noprelude(4,12,0) normalizePath fp = if "\\\\" `isPrefixOf` fp && not ("\\\\?\\" `isPrefixOf` fp) then "\\\\?\\UNC\\" ++ drop 2 fp
src/Text/Pandoc/App/FormatHeuristics.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.App.FormatHeuristics- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley@edu>@@ -15,7 +14,6 @@ ( formatFromFilePaths ) where -import Prelude import Data.Char (toLower) import Data.Text (Text) import System.FilePath (takeExtension)
src/Text/Pandoc/App/Opt.hs view
@@ -1,13 +1,12 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE FlexibleInstances #-} {- | Module : Text.Pandoc.App.Opt- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley@edu>@@ -23,7 +22,6 @@ , defaultOpts , addMeta ) where-import Prelude import Data.Char (isLower, toLower) import GHC.Generics hiding (Meta) import Text.Pandoc.Builder (setMeta)
src/Text/Pandoc/App/OutputSettings.hs view
@@ -1,12 +1,11 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TupleSections #-} {- | Module : Text.Pandoc.App- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley@edu>@@ -19,7 +18,6 @@ ( OutputSettings (..) , optToOutputSettings ) where-import Prelude import qualified Data.Map as M import qualified Data.Text as T import Text.DocTemplates (toVal, Context(..), Val(..))
src/Text/Pandoc/Asciify.hs view
@@ -1,7 +1,6 @@-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.Asciify- Copyright : Copyright (C) 2013-2019 John MacFarlane+ Copyright : Copyright (C) 2013-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -13,7 +12,6 @@ -} module Text.Pandoc.Asciify (toAsciiChar) where-import Prelude import Data.Char (isAscii) import qualified Data.Map as M
src/Text/Pandoc/BCP47.hs view
@@ -1,8 +1,7 @@ {-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.BCP47- Copyright : Copyright (C) 2017–2019 John MacFarlane+ Copyright : Copyright (C) 2017–2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -18,7 +17,6 @@ , renderLang ) where-import Prelude import Control.Monad (guard) import Data.Char (isAlphaNum, isAscii, isLetter, isLower, isUpper) import Text.Pandoc.Definition
src/Text/Pandoc/CSS.hs view
@@ -1,7 +1,6 @@-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.CSS-Copyright : © 2006-2019 John MacFarlane <jgm@berkeley.edu>,+Copyright : © 2006-2020 John MacFarlane <jgm@berkeley.edu>, 2015-2016 Mauro Bieg, 2015 Ophir Lifshitz <hangfromthefloor@gmail.com> License : GNU GPL, version 2 or above@@ -18,7 +17,6 @@ ) where -import Prelude import qualified Data.Text as T import Text.Pandoc.Shared (trim) import Text.Parsec
src/Text/Pandoc/CSV.hs view
@@ -1,7 +1,6 @@-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.CSV- Copyright : Copyright (C) 2017–2019 John MacFarlane <jgm@berkeley.edu>+ Copyright : Copyright (C) 2017–2020 John MacFarlane <jgm@berkeley.edu> License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu> Stability : alpha@@ -17,7 +16,6 @@ ParseError ) where -import Prelude import Control.Monad (unless, void) import Data.Text (Text) import qualified Data.Text as T
src/Text/Pandoc/Class.hs view
@@ -1,1068 +1,29 @@-{-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE CPP #-}-{-# LANGUAGE PatternGuards #-}-{-# LANGUAGE DeriveFunctor #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE UndecidableInstances #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE ViewPatterns #-}-{- |- Module : Text.Pandoc.Class- Copyright : Copyright (C) 2016-17 Jesse Rosenthal, John MacFarlane- License : GNU GPL, version 2 or above-- Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>- Stability : alpha- Portability : portable--This module defines a type class, 'PandocMonad', for pandoc readers-and writers. A pure instance 'PandocPure' and an impure instance-'PandocIO' are provided. This allows users of the library to choose-whether they want conversions to perform IO operations (such as-reading include files or images).--}--module Text.Pandoc.Class ( PandocMonad(..)- , CommonState(..)- , PureState(..)- , getPureState- , getsPureState- , putPureState- , modifyPureState- , getPOSIXTime- , getZonedTime- , readFileFromDirs- , report- , setTrace- , setRequestHeader- , getLog- , setVerbosity- , getVerbosity- , getMediaBag- , setMediaBag- , insertMedia- , setUserDataDir- , getUserDataDir- , fetchItem- , getInputFiles- , setInputFiles- , getOutputFile- , setOutputFile- , setResourcePath- , getResourcePath- , PandocIO(..)- , PandocPure(..)- , FileTree- , FileInfo(..)- , addToFileTree- , insertInFileTree- , runIO- , runIOorExplode- , runPure- , readDefaultDataFile- , readDataFile- , fetchMediaResource- , fillMediaBag- , extractMedia- , toLang- , setTranslations- , translateTerm- , Translations- ) where--import Prelude-import System.Random (StdGen, next, mkStdGen)-import qualified System.Random as IO (newStdGen)-import Codec.Archive.Zip-import qualified Data.CaseInsensitive as CI-import Data.Unique (hashUnique)-import qualified Data.Unique as IO (newUnique)-import qualified Text.Pandoc.UTF8 as UTF8-import qualified System.Directory as Directory-import Data.Time (UTCTime)-import Text.Pandoc.Logging-import Text.Pandoc.Shared (uriPathToPath)-import Text.Parsec (ParsecT, getPosition, sourceLine, sourceName)-import qualified Data.Time as IO (getCurrentTime)-import Text.Pandoc.MIME (MimeType, getMimeType, extensionFromMimeType)-import Text.Pandoc.Definition-import Data.Digest.Pure.SHA (sha1, showDigest)-import Data.Maybe (fromMaybe)-import Data.Time.Clock.POSIX ( utcTimeToPOSIXSeconds- , posixSecondsToUTCTime- , POSIXTime )-import Data.Time.LocalTime (TimeZone, ZonedTime, utcToZonedTime, utc)-import Data.ByteString.Base64 (decodeLenient)-import Network.URI ( escapeURIString, nonStrictRelativeTo,- unEscapeString, parseURIReference, isAllowedInURI,- parseURI, URI(..) )-import Network.HTTP.Client- (httpLbs, responseBody, responseHeaders,- Request(port, host, requestHeaders), parseRequest, newManager)-import Network.HTTP.Client.Internal (addProxy)-import Network.HTTP.Client.TLS (tlsManagerSettings)-import System.Environment (getEnv)-import Network.HTTP.Types.Header ( hContentType )-import Network.Socket (withSocketsDo)-import Data.ByteString.Lazy (toChunks)-import qualified Control.Exception as E-import qualified Data.Time.LocalTime as IO (getCurrentTimeZone)-import Text.Pandoc.MediaBag (MediaBag, lookupMedia, mediaDirectory)-import Text.Pandoc.Walk (walkM, walk)-import qualified Text.Pandoc.MediaBag as MB-import qualified Data.ByteString as B-import qualified Data.ByteString.Lazy as BL-import qualified System.Environment as IO (lookupEnv)-import System.FilePath.Glob (match, compile)-import System.Directory (createDirectoryIfMissing, getDirectoryContents,- doesDirectoryExist)-import System.FilePath- ((</>), (<.>), takeDirectory, takeExtension, dropExtension,- isRelative, normalise, splitDirectories)-import qualified System.FilePath.Glob as IO (glob)-import qualified System.FilePath.Posix as Posix-import qualified System.Directory as IO (getModificationTime)-import Control.Monad.State.Strict-import Control.Monad.Except-import Data.Word (Word8)-import Data.Default-import System.IO.Error-import System.IO (stderr)-import qualified Data.Map as M-import qualified Data.Text as T-import Text.Pandoc.Error-import Text.Pandoc.BCP47 (Lang(..), parseBCP47, renderLang)-import Text.Pandoc.Translations (Term(..), Translations, lookupTerm,- readTranslations)-import qualified Debug.Trace-#ifdef EMBED_DATA_FILES-import Text.Pandoc.Data (dataFiles)-#else-import qualified Paths_pandoc as Paths-#endif---- | The PandocMonad typeclass contains all the potentially--- IO-related functions used in pandoc's readers and writers.--- Instances of this typeclass may implement these functions--- in IO (as in 'PandocIO') or using an internal state that--- represents a file system, time, and so on (as in 'PandocPure').-class (Functor m, Applicative m, Monad m, MonadError PandocError m)- => PandocMonad m where- -- | Lookup an environment variable.- lookupEnv :: T.Text -> m (Maybe T.Text)- -- | Get the current (UTC) time.- getCurrentTime :: m UTCTime- -- | Get the locale's time zone.- getCurrentTimeZone :: m TimeZone- -- | Return a new generator for random numbers.- newStdGen :: m StdGen- -- | Return a new unique integer.- newUniqueHash :: m Int- -- | Retrieve contents and mime type from a URL, raising- -- an error on failure.- openURL :: T.Text -> m (B.ByteString, Maybe MimeType)- -- | Read the lazy ByteString contents from a file path,- -- raising an error on failure.- readFileLazy :: FilePath -> m BL.ByteString- -- | Read the strict ByteString contents from a file path,- -- raising an error on failure.- readFileStrict :: FilePath -> m B.ByteString- -- | Return a list of paths that match a glob, relative to- -- the working directory. See 'System.FilePath.Glob' for- -- the glob syntax.- glob :: String -> m [FilePath]- -- | Returns True if file exists.- fileExists :: FilePath -> m Bool- -- | Returns the path of data file.- getDataFileName :: FilePath -> m FilePath- -- | Return the modification time of a file.- getModificationTime :: FilePath -> m UTCTime- -- | Get the value of the 'CommonState' used by all instances- -- of 'PandocMonad'.- getCommonState :: m CommonState- -- | Set the value of the 'CommonState' used by all instances- -- of 'PandocMonad'.- -- | Get the value of a specific field of 'CommonState'.- putCommonState :: CommonState -> m ()- -- | Get the value of a specific field of 'CommonState'.- getsCommonState :: (CommonState -> a) -> m a- getsCommonState f = f <$> getCommonState- -- | Modify the 'CommonState'.- modifyCommonState :: (CommonState -> CommonState) -> m ()- modifyCommonState f = getCommonState >>= putCommonState . f- -- Output a log message.- logOutput :: LogMessage -> m ()- -- Output a debug message to sterr, using 'Debug.Trace.trace',- -- if tracing is enabled. Note: this writes to stderr even in- -- pure instances.- trace :: T.Text -> m ()- trace msg = do- tracing <- getsCommonState stTrace- when tracing $ Debug.Trace.trace ("[trace] " ++ T.unpack msg) (return ())---- * Functions defined for all PandocMonad instances---- | Set the verbosity level.-setVerbosity :: PandocMonad m => Verbosity -> m ()-setVerbosity verbosity =- modifyCommonState $ \st -> st{ stVerbosity = verbosity }---- | Get the verbosity level.-getVerbosity :: PandocMonad m => m Verbosity-getVerbosity = getsCommonState stVerbosity---- Get the accomulated log messages (in temporal order).-getLog :: PandocMonad m => m [LogMessage]-getLog = reverse <$> getsCommonState stLog---- | Log a message using 'logOutput'. Note that 'logOutput' is--- called only if the verbosity level exceeds the level of the--- message, but the message is added to the list of log messages--- that will be retrieved by 'getLog' regardless of its verbosity level.-report :: PandocMonad m => LogMessage -> m ()-report msg = do- verbosity <- getsCommonState stVerbosity- let level = messageVerbosity msg- when (level <= verbosity) $ logOutput msg- modifyCommonState $ \st -> st{ stLog = msg : stLog st }---- | Determine whether tracing is enabled. This affects--- the behavior of 'trace'. If tracing is not enabled,--- 'trace' does nothing.-setTrace :: PandocMonad m => Bool -> m ()-setTrace useTracing = modifyCommonState $ \st -> st{stTrace = useTracing}---- | Set request header to use in HTTP requests.-setRequestHeader :: PandocMonad m- => T.Text -- ^ Header name- -> T.Text -- ^ Value- -> m ()-setRequestHeader name val = modifyCommonState $ \st ->- st{ stRequestHeaders =- (name, val) : filter (\(n,_) -> n /= name) (stRequestHeaders st) }---- | Initialize the media bag.-setMediaBag :: PandocMonad m => MediaBag -> m ()-setMediaBag mb = modifyCommonState $ \st -> st{stMediaBag = mb}---- Retrieve the media bag.-getMediaBag :: PandocMonad m => m MediaBag-getMediaBag = getsCommonState stMediaBag---- Insert an item into the media bag.-insertMedia :: PandocMonad m => FilePath -> Maybe MimeType -> BL.ByteString -> m ()-insertMedia fp mime bs = do- mb <- getMediaBag- let mb' = MB.insertMedia fp mime bs mb- setMediaBag mb'---- Retrieve the input filenames.-getInputFiles :: PandocMonad m => m [FilePath]-getInputFiles = getsCommonState stInputFiles---- Set the input filenames.-setInputFiles :: PandocMonad m => [FilePath] -> m ()-setInputFiles fs = do- let sourceURL = case fs of- [] -> Nothing- (x:_) -> case parseURI x of- Just u- | uriScheme u `elem` ["http:","https:"] ->- Just $ show u{ uriQuery = "",- uriFragment = "" }- _ -> Nothing-- modifyCommonState $ \st -> st{ stInputFiles = fs- , stSourceURL = T.pack <$> sourceURL }---- Retrieve the output filename.-getOutputFile :: PandocMonad m => m (Maybe FilePath)-getOutputFile = getsCommonState stOutputFile---- Set the output filename.-setOutputFile :: PandocMonad m => Maybe FilePath -> m ()-setOutputFile mbf = modifyCommonState $ \st -> st{ stOutputFile = mbf }---- Retrieve the resource path searched by 'fetchItem'.-getResourcePath :: PandocMonad m => m [FilePath]-getResourcePath = getsCommonState stResourcePath---- Set the resource path searched by 'fetchItem'.-setResourcePath :: PandocMonad m => [FilePath] -> m ()-setResourcePath ps = modifyCommonState $ \st -> st{stResourcePath = ps}---- Get the POSIX time.-getPOSIXTime :: PandocMonad m => m POSIXTime-getPOSIXTime = utcTimeToPOSIXSeconds <$> getCurrentTime---- Get the zoned time.-getZonedTime :: PandocMonad m => m ZonedTime-getZonedTime = do- t <- getCurrentTime- tz <- getCurrentTimeZone- return $ utcToZonedTime tz t---- | Read file, checking in any number of directories.-readFileFromDirs :: PandocMonad m => [FilePath] -> FilePath -> m (Maybe T.Text)-readFileFromDirs [] _ = return Nothing-readFileFromDirs (d:ds) f = catchError- ((Just . T.pack . UTF8.toStringLazy) <$> readFileLazy (d </> f))- (\_ -> readFileFromDirs ds f)---- | 'CommonState' represents state that is used by all--- instances of 'PandocMonad'. Normally users should not--- need to interact with it directly; instead, auxiliary--- functions like 'setVerbosity' and 'withMediaBag' should be used.-data CommonState = CommonState { stLog :: [LogMessage]- -- ^ A list of log messages in reverse order- , stUserDataDir :: Maybe FilePath- -- ^ Directory to search for data files- , stSourceURL :: Maybe T.Text- -- ^ Absolute URL + dir of 1st source file- , stRequestHeaders :: [(T.Text, T.Text)]- -- ^ Headers to add for HTTP requests- , stMediaBag :: MediaBag- -- ^ Media parsed from binary containers- , stTranslations :: Maybe- (Lang, Maybe Translations)- -- ^ Translations for localization- , stInputFiles :: [FilePath]- -- ^ List of input files from command line- , stOutputFile :: Maybe FilePath- -- ^ Output file from command line- , stResourcePath :: [FilePath]- -- ^ Path to search for resources like- -- included images- , stVerbosity :: Verbosity- -- ^ Verbosity level- , stTrace :: Bool- -- ^ Controls whether tracing messages are- -- issued.- }--instance Default CommonState where- def = CommonState { stLog = []- , stUserDataDir = Nothing- , stSourceURL = Nothing- , stRequestHeaders = []- , stMediaBag = mempty- , stTranslations = Nothing- , stInputFiles = []- , stOutputFile = Nothing- , stResourcePath = ["."]- , stVerbosity = WARNING- , stTrace = False- }---- | Convert BCP47 string to a Lang, issuing warning--- if there are problems.-toLang :: PandocMonad m => Maybe T.Text -> m (Maybe Lang)-toLang Nothing = return Nothing-toLang (Just s) =- case parseBCP47 s of- Left _ -> do- report $ InvalidLang s- return Nothing- Right l -> return (Just l)---- | Select the language to use with 'translateTerm'.--- Note that this does not read a translation file;--- that is only done the first time 'translateTerm' is--- used.-setTranslations :: PandocMonad m => Lang -> m ()-setTranslations lang =- modifyCommonState $ \st -> st{ stTranslations = Just (lang, Nothing) }---- | Load term map.-getTranslations :: PandocMonad m => m Translations-getTranslations = do- mbtrans <- getsCommonState stTranslations- case mbtrans of- Nothing -> return mempty -- no language defined- Just (_, Just t) -> return t- Just (lang, Nothing) -> do -- read from file- let translationFile = "translations/" <> renderLang lang <> ".yaml"- let fallbackFile = "translations/" <> langLanguage lang <> ".yaml"- let getTrans fp = do- bs <- readDataFile fp- case readTranslations (UTF8.toText bs) of- Left e -> do- report $ CouldNotLoadTranslations (renderLang lang)- (T.pack fp <> ": " <> e)- -- make sure we don't try again...- modifyCommonState $ \st ->- st{ stTranslations = Nothing }- return mempty- Right t -> do- modifyCommonState $ \st ->- st{ stTranslations = Just (lang, Just t) }- return t- catchError (getTrans $ T.unpack translationFile)- (\_ ->- catchError (getTrans $ T.unpack fallbackFile)- (\e -> do- report $ CouldNotLoadTranslations (renderLang lang)- $ case e of- PandocCouldNotFindDataFileError _ ->- "data file " <> fallbackFile <> " not found"- _ -> ""- -- make sure we don't try again...- modifyCommonState $ \st -> st{ stTranslations = Nothing }- return mempty))---- | Get a translation from the current term map.--- Issue a warning if the term is not defined.-translateTerm :: PandocMonad m => Term -> m T.Text-translateTerm term = do- translations <- getTranslations- case lookupTerm term translations of- Just s -> return s- Nothing -> do- report $ NoTranslation $ T.pack $ show term- return ""---- | Evaluate a 'PandocIO' operation.-runIO :: PandocIO a -> IO (Either PandocError a)-runIO ma = flip evalStateT def $ runExceptT $ unPandocIO ma---- | Evaluate a 'PandocIO' operation, handling any errors--- by exiting with an appropriate message and error status.-runIOorExplode :: PandocIO a -> IO a-runIOorExplode ma = runIO ma >>= handleError--newtype PandocIO a = PandocIO {- unPandocIO :: ExceptT PandocError (StateT CommonState IO) a- } deriving ( MonadIO- , Functor- , Applicative- , Monad- , MonadError PandocError- )---- | Utility function to lift IO errors into 'PandocError's.-liftIOError :: (String -> IO a) -> String -> PandocIO a-liftIOError f u = do- res <- liftIO $ tryIOError $ f u- case res of- Left e -> throwError $ PandocIOError (T.pack u) e- Right r -> return r---- | Show potential IO errors to the user continuing execution anyway-logIOError :: IO () -> PandocIO ()-logIOError f = do- res <- liftIO $ tryIOError f- case res of- Left e -> report $ IgnoredIOError $ T.pack $ E.displayException e- Right _ -> pure ()--instance PandocMonad PandocIO where- lookupEnv = fmap (fmap T.pack) . liftIO . IO.lookupEnv . T.unpack- getCurrentTime = liftIO IO.getCurrentTime- getCurrentTimeZone = liftIO IO.getCurrentTimeZone- newStdGen = liftIO IO.newStdGen- newUniqueHash = hashUnique <$> liftIO IO.newUnique-- openURL u- | Just u'' <- T.stripPrefix "data:" u = do- let mime = T.takeWhile (/=',') u''- let contents = UTF8.fromString $- unEscapeString $ T.unpack $ T.drop 1 $ T.dropWhile (/=',') u''- return (decodeLenient contents, Just mime)- | otherwise = do- let toReqHeader (n, v) = (CI.mk (UTF8.fromText n), UTF8.fromText v)- customHeaders <- map toReqHeader <$> getsCommonState stRequestHeaders- report $ Fetching u- res <- liftIO $ E.try $ withSocketsDo $ do- let parseReq = parseRequest- proxy <- tryIOError (getEnv "http_proxy")- let addProxy' x = case proxy of- Left _ -> return x- Right pr -> parseReq pr >>= \r ->- return (addProxy (host r) (port r) x)- req <- parseReq (T.unpack u) >>= addProxy'- let req' = req{requestHeaders = customHeaders ++ requestHeaders req}- resp <- newManager tlsManagerSettings >>= httpLbs req'- return (B.concat $ toChunks $ responseBody resp,- UTF8.toText `fmap` lookup hContentType (responseHeaders resp))-- case res of- Right r -> return r- Left e -> throwError $ PandocHttpError u e-- readFileLazy s = liftIOError BL.readFile s- readFileStrict s = liftIOError B.readFile s-- glob = liftIOError IO.glob- fileExists = liftIOError Directory.doesFileExist-#ifdef EMBED_DATA_FILES- getDataFileName = return-#else- getDataFileName = liftIOError Paths.getDataFileName-#endif- getModificationTime = liftIOError IO.getModificationTime- getCommonState = PandocIO $ lift get- putCommonState x = PandocIO $ lift $ put x- logOutput msg = liftIO $ do- UTF8.hPutStr stderr $- "[" ++ show (messageVerbosity msg) ++ "] "- alertIndent $ T.lines $ showLogMessage msg--alertIndent :: [T.Text] -> IO ()-alertIndent [] = return ()-alertIndent (l:ls) = do- UTF8.hPutStrLn stderr $ T.unpack l- mapM_ go ls- where go l' = do UTF8.hPutStr stderr " "- UTF8.hPutStrLn stderr $ T.unpack l'---- | Specialized version of parseURIReference that disallows--- single-letter schemes. Reason: these are usually windows absolute--- paths.-parseURIReference' :: T.Text -> Maybe URI-parseURIReference' s = do- u <- parseURIReference (T.unpack s)- case uriScheme u of- [_] -> Nothing- _ -> Just u---- | Set the user data directory in common state.-setUserDataDir :: PandocMonad m- => Maybe FilePath- -> m ()-setUserDataDir mbfp = modifyCommonState $ \st -> st{ stUserDataDir = mbfp }---- | Get the user data directory from common state.-getUserDataDir :: PandocMonad m- => m (Maybe FilePath)-getUserDataDir = getsCommonState stUserDataDir---- | Fetch an image or other item from the local filesystem or the net.--- Returns raw content and maybe mime type.-fetchItem :: PandocMonad m- => T.Text- -> m (B.ByteString, Maybe MimeType)-fetchItem s = do- mediabag <- getMediaBag- case lookupMedia (T.unpack s) mediabag of- Just (mime, bs) -> return (BL.toStrict bs, Just mime)- Nothing -> downloadOrRead s--downloadOrRead :: PandocMonad m- => T.Text- -> m (B.ByteString, Maybe MimeType)-downloadOrRead s = do- sourceURL <- getsCommonState stSourceURL- case (sourceURL >>= parseURIReference' .- ensureEscaped, ensureEscaped s) of- (Just u, s') -> -- try fetching from relative path at source- case parseURIReference' s' of- Just u' -> openURL $ T.pack $ show $ u' `nonStrictRelativeTo` u- Nothing -> openURL s' -- will throw error- (Nothing, s'@(T.unpack -> ('/':'/':c:_))) | c /= '?' -> -- protocol-relative URI- -- we exclude //? because of //?UNC/ on Windows- case parseURIReference' s' of- Just u' -> openURL $ T.pack $ show $ u' `nonStrictRelativeTo` httpcolon- Nothing -> openURL s' -- will throw error- (Nothing, s') ->- case parseURI (T.unpack s') of -- requires absolute URI- Just u' | uriScheme u' == "file:" ->- readLocalFile $ uriPathToPath (T.pack $ uriPath u')- -- We don't want to treat C:/ as a scheme:- Just u' | length (uriScheme u') > 2 -> openURL (T.pack $ show u')- _ -> readLocalFile fp -- get from local file system- where readLocalFile f = do- resourcePath <- getResourcePath- cont <- if isRelative f- then withPaths resourcePath readFileStrict f- else readFileStrict f- return (cont, mime)- httpcolon = URI{ uriScheme = "http:",- uriAuthority = Nothing,- uriPath = "",- uriQuery = "",- uriFragment = "" }- dropFragmentAndQuery = T.takeWhile (\c -> c /= '?' && c /= '#')- fp = unEscapeString $ T.unpack $ dropFragmentAndQuery s- mime = getMimeType $ case takeExtension fp of- ".gz" -> dropExtension fp- ".svgz" -> dropExtension fp ++ ".svg"- x -> x- ensureEscaped = T.pack . escapeURIString isAllowedInURI . T.unpack . T.map convertSlash- convertSlash '\\' = '/'- convertSlash x = x---- Retrieve default reference.docx.-getDefaultReferenceDocx :: PandocMonad m => m Archive-getDefaultReferenceDocx = do- let paths = ["[Content_Types].xml",- "_rels/.rels",- "docProps/app.xml",- "docProps/core.xml",- "docProps/custom.xml",- "word/document.xml",- "word/fontTable.xml",- "word/footnotes.xml",- "word/comments.xml",- "word/numbering.xml",- "word/settings.xml",- "word/webSettings.xml",- "word/styles.xml",- "word/_rels/document.xml.rels",- "word/_rels/footnotes.xml.rels",- "word/theme/theme1.xml"]- let toLazy = BL.fromChunks . (:[])- let pathToEntry path = do- epochtime <- (floor . utcTimeToPOSIXSeconds) <$> getCurrentTime- contents <- toLazy <$> readDataFile ("docx/" ++ path)- return $ toEntry path epochtime contents- datadir <- getUserDataDir- mbArchive <- case datadir of- Nothing -> return Nothing- Just d -> do- exists <- fileExists (d </> "reference.docx")- if exists- then return (Just (d </> "reference.docx"))- else return Nothing- case mbArchive of- Just arch -> toArchive <$> readFileLazy arch- Nothing -> foldr addEntryToArchive emptyArchive <$>- mapM pathToEntry paths---- Retrieve default reference.odt.-getDefaultReferenceODT :: PandocMonad m => m Archive-getDefaultReferenceODT = do- let paths = ["mimetype",- "manifest.rdf",- "styles.xml",- "content.xml",- "meta.xml",- "settings.xml",- "Configurations2/accelerator/current.xml",- "Thumbnails/thumbnail.png",- "META-INF/manifest.xml"]- let pathToEntry path = do epochtime <- floor `fmap` getPOSIXTime- contents <- (BL.fromChunks . (:[])) `fmap`- readDataFile ("odt/" ++ path)- return $ toEntry path epochtime contents- datadir <- getUserDataDir- mbArchive <- case datadir of- Nothing -> return Nothing- Just d -> do- exists <- fileExists (d </> "reference.odt")- if exists- then return (Just (d </> "reference.odt"))- else return Nothing- case mbArchive of- Just arch -> toArchive <$> readFileLazy arch- Nothing -> foldr addEntryToArchive emptyArchive <$>- mapM pathToEntry paths--getDefaultReferencePptx :: PandocMonad m => m Archive-getDefaultReferencePptx = do- -- We're going to narrow this down substantially once we get it- -- working.- let paths = [ "[Content_Types].xml"- , "_rels/.rels"- , "docProps/app.xml"- , "docProps/core.xml"- , "ppt/_rels/presentation.xml.rels"- , "ppt/presProps.xml"- , "ppt/presentation.xml"- , "ppt/slideLayouts/_rels/slideLayout1.xml.rels"- , "ppt/slideLayouts/_rels/slideLayout2.xml.rels"- , "ppt/slideLayouts/_rels/slideLayout3.xml.rels"- , "ppt/slideLayouts/_rels/slideLayout4.xml.rels"- , "ppt/slideLayouts/_rels/slideLayout5.xml.rels"- , "ppt/slideLayouts/_rels/slideLayout6.xml.rels"- , "ppt/slideLayouts/_rels/slideLayout7.xml.rels"- , "ppt/slideLayouts/_rels/slideLayout8.xml.rels"- , "ppt/slideLayouts/_rels/slideLayout9.xml.rels"- , "ppt/slideLayouts/_rels/slideLayout10.xml.rels"- , "ppt/slideLayouts/_rels/slideLayout11.xml.rels"- , "ppt/slideLayouts/slideLayout1.xml"- , "ppt/slideLayouts/slideLayout10.xml"- , "ppt/slideLayouts/slideLayout11.xml"- , "ppt/slideLayouts/slideLayout2.xml"- , "ppt/slideLayouts/slideLayout3.xml"- , "ppt/slideLayouts/slideLayout4.xml"- , "ppt/slideLayouts/slideLayout5.xml"- , "ppt/slideLayouts/slideLayout6.xml"- , "ppt/slideLayouts/slideLayout7.xml"- , "ppt/slideLayouts/slideLayout8.xml"- , "ppt/slideLayouts/slideLayout9.xml"- , "ppt/slideMasters/_rels/slideMaster1.xml.rels"- , "ppt/slideMasters/slideMaster1.xml"- , "ppt/slides/_rels/slide1.xml.rels"- , "ppt/slides/slide1.xml"- , "ppt/slides/_rels/slide2.xml.rels"- , "ppt/slides/slide2.xml"- , "ppt/slides/_rels/slide3.xml.rels"- , "ppt/slides/slide3.xml"- , "ppt/slides/_rels/slide4.xml.rels"- , "ppt/slides/slide4.xml"- , "ppt/tableStyles.xml"- , "ppt/theme/theme1.xml"- , "ppt/viewProps.xml"- -- These relate to notes slides.- , "ppt/notesMasters/notesMaster1.xml"- , "ppt/notesMasters/_rels/notesMaster1.xml.rels"- , "ppt/notesSlides/notesSlide1.xml"- , "ppt/notesSlides/_rels/notesSlide1.xml.rels"- , "ppt/notesSlides/notesSlide2.xml"- , "ppt/notesSlides/_rels/notesSlide2.xml.rels"- , "ppt/theme/theme2.xml"- ]- let toLazy = BL.fromChunks . (:[])- let pathToEntry path = do- epochtime <- (floor . utcTimeToPOSIXSeconds) <$> getCurrentTime- contents <- toLazy <$> readDataFile ("pptx/" ++ path)- return $ toEntry path epochtime contents- datadir <- getUserDataDir- mbArchive <- case datadir of- Nothing -> return Nothing- Just d -> do- exists <- fileExists (d </> "reference.pptx")- if exists- then return (Just (d </> "reference.pptx"))- else return Nothing- case mbArchive of- Just arch -> toArchive <$> readFileLazy arch- Nothing -> foldr addEntryToArchive emptyArchive <$>- mapM pathToEntry paths----- | Read file from user data directory or,--- if not found there, from Cabal data directory.-readDataFile :: PandocMonad m => FilePath -> m B.ByteString-readDataFile fname = do- datadir <- getUserDataDir- case datadir of- Nothing -> readDefaultDataFile fname- Just userDir -> do- exists <- fileExists (userDir </> fname)- if exists- then readFileStrict (userDir </> fname)- else readDefaultDataFile fname---- | Read file from from Cabal data directory.-readDefaultDataFile :: PandocMonad m => FilePath -> m B.ByteString-readDefaultDataFile "reference.docx" =- (B.concat . BL.toChunks . fromArchive) <$> getDefaultReferenceDocx-readDefaultDataFile "reference.pptx" =- (B.concat . BL.toChunks . fromArchive) <$> getDefaultReferencePptx-readDefaultDataFile "reference.odt" =- (B.concat . BL.toChunks . fromArchive) <$> getDefaultReferenceODT-readDefaultDataFile fname =-#ifdef EMBED_DATA_FILES- case lookup (makeCanonical fname) dataFiles of- Nothing -> throwError $ PandocCouldNotFindDataFileError $ T.pack fname- Just contents -> return contents-#else- getDataFileName fname' >>= checkExistence >>= readFileStrict- where fname' = if fname == "MANUAL.txt" then fname else "data" </> fname--checkExistence :: PandocMonad m => FilePath -> m FilePath-checkExistence fn = do- exists <- fileExists fn- if exists- then return fn- else throwError $ PandocCouldNotFindDataFileError $ T.pack fn-#endif--makeCanonical :: FilePath -> FilePath-makeCanonical = Posix.joinPath . transformPathParts . splitDirectories- where transformPathParts = reverse . foldl go []- go as "." = as- go (_:as) ".." = as- go as x = x : as--withPaths :: PandocMonad m => [FilePath] -> (FilePath -> m a) -> FilePath -> m a-withPaths [] _ fp = throwError $ PandocResourceNotFound $ T.pack fp-withPaths (p:ps) action fp =- catchError (action (p </> fp))- (\_ -> withPaths ps action fp)---- | Fetch local or remote resource (like an image) and provide data suitable--- for adding it to the MediaBag.-fetchMediaResource :: PandocMonad m- => T.Text -> m (FilePath, Maybe MimeType, BL.ByteString)-fetchMediaResource src = do- (bs, mt) <- downloadOrRead src- let ext = fromMaybe (T.pack $ takeExtension $ T.unpack src)- (mt >>= extensionFromMimeType)- let bs' = BL.fromChunks [bs]- let basename = showDigest $ sha1 bs'- let fname = basename <.> T.unpack ext- return (fname, mt, bs')---- | Traverse tree, filling media bag for any images that--- aren't already in the media bag.-fillMediaBag :: PandocMonad m => Pandoc -> m Pandoc-fillMediaBag d = walkM handleImage d- where handleImage :: PandocMonad m => Inline -> m Inline- handleImage (Image attr lab (src, tit)) = catchError- (do mediabag <- getMediaBag- case lookupMedia (T.unpack src) mediabag of- Just (_, _) -> return $ Image attr lab (src, tit)- Nothing -> do- (fname, mt, bs) <- fetchMediaResource src- insertMedia fname mt bs- return $ Image attr lab (T.pack fname, tit))- (\e ->- case e of- PandocResourceNotFound _ -> do- report $ CouldNotFetchResource src- "replacing image with description"- -- emit alt text- return $ Span ("",["image"],[]) lab- PandocHttpError u er -> do- report $ CouldNotFetchResource u- (T.pack $ show er ++ "\rReplacing image with description.")- -- emit alt text- return $ Span ("",["image"],[]) lab- _ -> throwError e)- handleImage x = return x---- | Extract media from the mediabag into a directory.-extractMedia :: FilePath -> Pandoc -> PandocIO Pandoc-extractMedia dir d = do- media <- getMediaBag- case [fp | (fp, _, _) <- mediaDirectory media] of- [] -> return d- fps -> do- mapM_ (writeMedia dir media) fps- return $ walk (adjustImagePath dir fps) d---- Write the contents of a media bag to a path.-writeMedia :: FilePath -> MediaBag -> FilePath -> PandocIO ()-writeMedia dir mediabag subpath = do- -- we join and split to convert a/b/c to a\b\c on Windows;- -- in zip containers all paths use /- let fullpath = dir </> unEscapeString (normalise subpath)- let mbcontents = lookupMedia subpath mediabag- case mbcontents of- Nothing -> throwError $ PandocResourceNotFound $ T.pack subpath- Just (_, bs) -> do- report $ Extracting $ T.pack fullpath- liftIOError (createDirectoryIfMissing True) (takeDirectory fullpath)- logIOError $ BL.writeFile fullpath bs--adjustImagePath :: FilePath -> [FilePath] -> Inline -> Inline-adjustImagePath dir paths (Image attr lab (src, tit))- | T.unpack src `elem` paths = Image attr lab (T.pack dir <> "/" <> src, tit)-adjustImagePath _ _ x = x---- | The 'PureState' contains ersatz representations--- of things that would normally be obtained through IO.-data PureState = PureState { stStdGen :: StdGen- , stWord8Store :: [Word8] -- should be- -- infinite,- -- i.e. [1..]- , stUniqStore :: [Int] -- should be- -- infinite and- -- contain every- -- element at most- -- once, e.g. [1..]- , stEnv :: [(T.Text, T.Text)]- , stTime :: UTCTime- , stTimeZone :: TimeZone- , stReferenceDocx :: Archive- , stReferencePptx :: Archive- , stReferenceODT :: Archive- , stFiles :: FileTree- , stUserDataFiles :: FileTree- , stCabalDataFiles :: FileTree- }--instance Default PureState where- def = PureState { stStdGen = mkStdGen 1848- , stWord8Store = [1..]- , stUniqStore = [1..]- , stEnv = [("USER", "pandoc-user")]- , stTime = posixSecondsToUTCTime 0- , stTimeZone = utc- , stReferenceDocx = emptyArchive- , stReferencePptx = emptyArchive- , stReferenceODT = emptyArchive- , stFiles = mempty- , stUserDataFiles = mempty- , stCabalDataFiles = mempty- }---getPureState :: PandocPure PureState-getPureState = PandocPure $ lift $ lift get--getsPureState :: (PureState -> a) -> PandocPure a-getsPureState f = f <$> getPureState--putPureState :: PureState -> PandocPure ()-putPureState ps= PandocPure $ lift $ lift $ put ps--modifyPureState :: (PureState -> PureState) -> PandocPure ()-modifyPureState f = PandocPure $ lift $ lift $ modify f---data FileInfo = FileInfo { infoFileMTime :: UTCTime- , infoFileContents :: B.ByteString- }--newtype FileTree = FileTree {unFileTree :: M.Map FilePath FileInfo}- deriving (Semigroup, Monoid)--getFileInfo :: FilePath -> FileTree -> Maybe FileInfo-getFileInfo fp tree =- M.lookup (makeCanonical fp) (unFileTree tree)---- | Add the specified file to the FileTree. If file--- is a directory, add its contents recursively.-addToFileTree :: FileTree -> FilePath -> IO FileTree-addToFileTree tree fp = do- isdir <- doesDirectoryExist fp- if isdir- then do -- recursively add contents of directories- let isSpecial ".." = True- isSpecial "." = True- isSpecial _ = False- fs <- (map (fp </>) . filter (not . isSpecial)) <$> getDirectoryContents fp- foldM addToFileTree tree fs- else do- contents <- B.readFile fp- mtime <- IO.getModificationTime fp- return $ insertInFileTree fp FileInfo{ infoFileMTime = mtime- , infoFileContents = contents } tree---- | Insert an ersatz file into the 'FileTree'.-insertInFileTree :: FilePath -> FileInfo -> FileTree -> FileTree-insertInFileTree fp info (FileTree treemap) =- FileTree $ M.insert (makeCanonical fp) info treemap--newtype PandocPure a = PandocPure {- unPandocPure :: ExceptT PandocError- (StateT CommonState (State PureState)) a- } deriving ( Functor- , Applicative- , Monad- , MonadError PandocError- )---- Run a 'PandocPure' operation.-runPure :: PandocPure a -> Either PandocError a-runPure x = flip evalState def $- flip evalStateT def $- runExceptT $- unPandocPure x--instance PandocMonad PandocPure where- lookupEnv s = do- env <- getsPureState stEnv- return (lookup s env)-- getCurrentTime = getsPureState stTime-- getCurrentTimeZone = getsPureState stTimeZone-- newStdGen = do- g <- getsPureState stStdGen- let (_, nxtGen) = next g- modifyPureState $ \st -> st { stStdGen = nxtGen }- return g-- newUniqueHash = do- uniqs <- getsPureState stUniqStore- case uniqs of- u : us -> do- modifyPureState $ \st -> st { stUniqStore = us }- return u- _ -> throwError $ PandocShouldNeverHappenError- "uniq store ran out of elements"- openURL u = throwError $ PandocResourceNotFound u- readFileLazy fp = do- fps <- getsPureState stFiles- case infoFileContents <$> getFileInfo fp fps of- Just bs -> return (BL.fromStrict bs)- Nothing -> throwError $ PandocResourceNotFound $ T.pack fp- readFileStrict fp = do- fps <- getsPureState stFiles- case infoFileContents <$> getFileInfo fp fps of- Just bs -> return bs- Nothing -> throwError $ PandocResourceNotFound $ T.pack fp-- glob s = do- FileTree ftmap <- getsPureState stFiles- return $ filter (match (compile s)) $ M.keys ftmap-- fileExists fp = do- fps <- getsPureState stFiles- case getFileInfo fp fps of- Nothing -> return False- Just _ -> return True-- getDataFileName fp = return $ "data/" ++ fp-- getModificationTime fp = do- fps <- getsPureState stFiles- case infoFileMTime <$> getFileInfo fp fps of- Just tm -> return tm- Nothing -> throwError $ PandocIOError (T.pack fp)- (userError "Can't get modification time")-- getCommonState = PandocPure $ lift get- putCommonState x = PandocPure $ lift $ put x-- logOutput _msg = return ()---- This requires UndecidableInstances. We could avoid that--- by repeating the definitions below for every monad transformer--- we use: ReaderT, WriterT, StateT, RWST. But this seems to--- be harmless.-instance (MonadTrans t, PandocMonad m, Functor (t m),- MonadError PandocError (t m), Monad (t m),- Applicative (t m)) => PandocMonad (t m) where- lookupEnv = lift . lookupEnv- getCurrentTime = lift getCurrentTime- getCurrentTimeZone = lift getCurrentTimeZone- newStdGen = lift newStdGen- newUniqueHash = lift newUniqueHash- openURL = lift . openURL- readFileLazy = lift . readFileLazy- readFileStrict = lift . readFileStrict- glob = lift . glob- fileExists = lift . fileExists- getDataFileName = lift . getDataFileName- getModificationTime = lift . getModificationTime- getCommonState = lift getCommonState- putCommonState = lift . putCommonState- logOutput = lift . logOutput--instance {-# OVERLAPS #-} PandocMonad m => PandocMonad (ParsecT s st m) where- lookupEnv = lift . lookupEnv- getCurrentTime = lift getCurrentTime- getCurrentTimeZone = lift getCurrentTimeZone- newStdGen = lift newStdGen- newUniqueHash = lift newUniqueHash- openURL = lift . openURL- readFileLazy = lift . readFileLazy- readFileStrict = lift . readFileStrict- glob = lift . glob- fileExists = lift . fileExists- getDataFileName = lift . getDataFileName- getModificationTime = lift . getModificationTime- getCommonState = lift getCommonState- putCommonState = lift . putCommonState- trace msg = do- tracing <- getsCommonState stTrace- when tracing $ do- pos <- getPosition- Debug.Trace.trace- ("[trace] Parsed " ++ T.unpack msg ++ " at line " ++- show (sourceLine pos) ++- if sourceName pos == "chunk"- then " of chunk"- else "")- (return ())- logOutput = lift . logOutput+{- |+ Module : Text.Pandoc.Class+ Copyright : Copyright (C) 2016-2020 Jesse Rosenthal, John MacFarlane+ License : GNU GPL, version 2 or above++ Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>+ Stability : alpha+ Portability : portable++This module defines a type class, 'PandocMonad', for pandoc readers+and writers. A pure instance 'PandocPure' and an impure instance+'PandocIO' are provided. This allows users of the library to choose+whether they want conversions to perform IO operations (such as+reading include files or images).+-}++module Text.Pandoc.Class+ ( module Text.Pandoc.Class.CommonState+ , module Text.Pandoc.Class.PandocIO+ , module Text.Pandoc.Class.PandocMonad+ , module Text.Pandoc.Class.PandocPure+ , Translations+ ) where++import Text.Pandoc.Class.CommonState (CommonState (..))+import Text.Pandoc.Class.PandocMonad+import Text.Pandoc.Class.PandocIO+import Text.Pandoc.Class.PandocPure+import Text.Pandoc.Translations (Translations)
+ src/Text/Pandoc/Class/CommonState.hs view
@@ -0,0 +1,80 @@+{- |+Module : Text.Pandoc.Class.CommonState+Copyright : Copyright (C) 2016-2020 Jesse Rosenthal, John MacFarlane+License : GNU GPL, version 2 or above++Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>+Stability : alpha+Portability : portable++Common state shared by all pandoc-specific operations, including+those in readers, writers, and Lua filters.+-}++module Text.Pandoc.Class.CommonState+ ( CommonState(..)+ , defaultCommonState+ )+where++import Data.Default (Default (def))+import Data.Text (Text)+import Text.Pandoc.BCP47 (Lang)+import Text.Pandoc.MediaBag (MediaBag)+import Text.Pandoc.Logging (LogMessage, Verbosity (WARNING))+import Text.Pandoc.Translations (Translations)++-- | 'CommonState' represents state that is used by all+-- instances of 'PandocMonad'. Normally users should not+-- need to interact with it directly; instead, auxiliary+-- functions like 'setVerbosity' and 'withMediaBag' should be used.+data CommonState = CommonState+ { stLog :: [LogMessage]+ -- ^ A list of log messages in reverse order+ , stUserDataDir :: Maybe FilePath+ -- ^ Directory to search for data files+ , stSourceURL :: Maybe Text+ -- ^ Absolute URL + dir of 1st source file+ , stRequestHeaders :: [(Text, Text)]+ -- ^ Headers to add for HTTP requests+ , stMediaBag :: MediaBag+ -- ^ Media parsed from binary containers+ , stTranslations :: Maybe (Lang, Maybe Translations)+ -- ^ Translations for localization+ , stInputFiles :: [FilePath]+ -- ^ List of input files from command line+ , stOutputFile :: Maybe FilePath+ -- ^ Output file from command line+ , stResourcePath :: [FilePath]+ -- ^ Path to search for resources like+ -- included images+ , stVerbosity :: Verbosity+ -- ^ Verbosity level+ , stTrace :: Bool+ -- ^ Controls whether tracing messages are+ -- issued.+ }++-- | The default @'CommonState'@. All fields are initialized as the+-- monoid identity of their resprective type, except for:+--+-- * @'stResourcePath'@, which is set to @["."]@,+-- * @'stTrace'@, which is set to @'False'@, and+-- * @'stVerbosity'@, which is set to @WARNING@.+defaultCommonState :: CommonState+defaultCommonState = CommonState+ { stLog = []+ , stUserDataDir = Nothing+ , stSourceURL = Nothing+ , stRequestHeaders = []+ , stMediaBag = mempty+ , stTranslations = Nothing+ , stInputFiles = []+ , stOutputFile = Nothing+ , stResourcePath = ["."]+ , stVerbosity = WARNING+ , stTrace = False+ }++instance Default CommonState where+ def = defaultCommonState
+ src/Text/Pandoc/Class/PandocIO.hs view
@@ -0,0 +1,218 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE DeriveFunctor #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE OverloadedStrings #-}+{- |+Module : Text.Pandoc.Class.PandocIO+Copyright : Copyright (C) 2016-2020 Jesse Rosenthal, John MacFarlane+License : GNU GPL, version 2 or above++Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>+Stability : alpha+Portability : portable++This module defines @'PandocIO'@, an IO-based instance of the+@'PandocMonad'@ type class. File, data, and network access all are run+using IO operators.+-}+module Text.Pandoc.Class.PandocIO+ ( getPOSIXTime+ , getZonedTime+ , readFileFromDirs+ , report+ , setTrace+ , setRequestHeader+ , getLog+ , setVerbosity+ , getVerbosity+ , getMediaBag+ , setMediaBag+ , insertMedia+ , setUserDataDir+ , getUserDataDir+ , fetchItem+ , getInputFiles+ , setInputFiles+ , getOutputFile+ , setOutputFile+ , setResourcePath+ , getResourcePath+ , PandocIO(..)+ , runIO+ , runIOorExplode+ , extractMedia+ ) where++import Control.Monad.Except+import Control.Monad.State.Strict+import Data.ByteString.Base64 (decodeLenient)+import Data.ByteString.Lazy (toChunks)+import Data.Default+import Data.Text (Text)+import Data.Unique (hashUnique)+import Network.HTTP.Client+ (httpLbs, responseBody, responseHeaders,+ Request(port, host, requestHeaders), parseRequest, newManager)+import Network.HTTP.Client.Internal (addProxy)+import Network.HTTP.Client.TLS (tlsManagerSettings)+import Network.HTTP.Types.Header ( hContentType )+import Network.Socket (withSocketsDo)+import Network.URI ( unEscapeString )+import Prelude+import System.Directory (createDirectoryIfMissing)+import System.Environment (getEnv)+import System.FilePath ((</>), takeDirectory, normalise)+import System.IO (stderr)+import System.IO.Error+import Text.Pandoc.Class.CommonState (CommonState (..))+import Text.Pandoc.Class.PandocMonad+import Text.Pandoc.Definition+import Text.Pandoc.Error+import Text.Pandoc.Logging+import Text.Pandoc.MediaBag (MediaBag, lookupMedia, mediaDirectory)+import Text.Pandoc.Walk (walk)+import qualified Control.Exception as E+import qualified Data.ByteString as B+import qualified Data.ByteString.Lazy as BL+import qualified Data.CaseInsensitive as CI+import qualified Data.Text as T+import qualified Data.Time as IO (getCurrentTime)+import qualified Data.Time.LocalTime as IO (getCurrentTimeZone)+import qualified Data.Unique as IO (newUnique)+import qualified System.Directory as Directory+import qualified System.Directory as IO (getModificationTime)+import qualified System.Environment as IO (lookupEnv)+import qualified System.FilePath.Glob as IO (glob)+import qualified System.Random as IO (newStdGen)+import qualified Text.Pandoc.UTF8 as UTF8+#ifndef EMBED_DATA_FILES+import qualified Paths_pandoc as Paths+#endif++-- | Evaluate a 'PandocIO' operation.+runIO :: PandocIO a -> IO (Either PandocError a)+runIO ma = flip evalStateT def $ runExceptT $ unPandocIO ma++-- | Evaluate a 'PandocIO' operation, handling any errors+-- by exiting with an appropriate message and error status.+runIOorExplode :: PandocIO a -> IO a+runIOorExplode ma = runIO ma >>= handleError++newtype PandocIO a = PandocIO {+ unPandocIO :: ExceptT PandocError (StateT CommonState IO) a+ } deriving ( MonadIO+ , Functor+ , Applicative+ , Monad+ , MonadError PandocError+ )++-- | Utility function to lift IO errors into 'PandocError's.+liftIOError :: (String -> IO a) -> String -> PandocIO a+liftIOError f u = do+ res <- liftIO $ tryIOError $ f u+ case res of+ Left e -> throwError $ PandocIOError (T.pack u) e+ Right r -> return r++-- | Show potential IO errors to the user continuing execution anyway+logIOError :: IO () -> PandocIO ()+logIOError f = do+ res <- liftIO $ tryIOError f+ case res of+ Left e -> report $ IgnoredIOError $ T.pack $ E.displayException e+ Right _ -> pure ()++instance PandocMonad PandocIO where+ lookupEnv = fmap (fmap T.pack) . liftIO . IO.lookupEnv . T.unpack+ getCurrentTime = liftIO IO.getCurrentTime+ getCurrentTimeZone = liftIO IO.getCurrentTimeZone+ newStdGen = liftIO IO.newStdGen+ newUniqueHash = hashUnique <$> liftIO IO.newUnique++ openURL u+ | Just u'' <- T.stripPrefix "data:" u = do+ let mime = T.takeWhile (/=',') u''+ let contents = UTF8.fromString $+ unEscapeString $ T.unpack $ T.drop 1 $ T.dropWhile (/=',') u''+ return (decodeLenient contents, Just mime)+ | otherwise = do+ let toReqHeader (n, v) = (CI.mk (UTF8.fromText n), UTF8.fromText v)+ customHeaders <- map toReqHeader <$> getsCommonState stRequestHeaders+ report $ Fetching u+ res <- liftIO $ E.try $ withSocketsDo $ do+ let parseReq = parseRequest+ proxy <- tryIOError (getEnv "http_proxy")+ let addProxy' x = case proxy of+ Left _ -> return x+ Right pr -> parseReq pr >>= \r ->+ return (addProxy (host r) (port r) x)+ req <- parseReq (T.unpack u) >>= addProxy'+ let req' = req{requestHeaders = customHeaders ++ requestHeaders req}+ resp <- newManager tlsManagerSettings >>= httpLbs req'+ return (B.concat $ toChunks $ responseBody resp,+ UTF8.toText `fmap` lookup hContentType (responseHeaders resp))++ case res of+ Right r -> return r+ Left e -> throwError $ PandocHttpError u e++ readFileLazy s = liftIOError BL.readFile s+ readFileStrict s = liftIOError B.readFile s++ glob = liftIOError IO.glob+ fileExists = liftIOError Directory.doesFileExist+#ifdef EMBED_DATA_FILES+ getDataFileName = return+#else+ getDataFileName = liftIOError Paths.getDataFileName+#endif+ getModificationTime = liftIOError IO.getModificationTime+ getCommonState = PandocIO $ lift get+ putCommonState x = PandocIO $ lift $ put x+ logOutput msg = liftIO $ do+ UTF8.hPutStr stderr $+ "[" ++ show (messageVerbosity msg) ++ "] "+ alertIndent $ T.lines $ showLogMessage msg++-- | Prints the list of lines to @stderr@, indenting every but the first+-- line by two spaces.+alertIndent :: [Text] -> IO ()+alertIndent [] = return ()+alertIndent (l:ls) = do+ UTF8.hPutStrLn stderr $ T.unpack l+ mapM_ go ls+ where go l' = do UTF8.hPutStr stderr " "+ UTF8.hPutStrLn stderr $ T.unpack l'++-- | Extract media from the mediabag into a directory.+extractMedia :: FilePath -> Pandoc -> PandocIO Pandoc+extractMedia dir d = do+ media <- getMediaBag+ case [fp | (fp, _, _) <- mediaDirectory media] of+ [] -> return d+ fps -> do+ mapM_ (writeMedia dir media) fps+ return $ walk (adjustImagePath dir fps) d++-- | Write the contents of a media bag to a path.+writeMedia :: FilePath -> MediaBag -> FilePath -> PandocIO ()+writeMedia dir mediabag subpath = do+ -- we join and split to convert a/b/c to a\b\c on Windows;+ -- in zip containers all paths use /+ let fullpath = dir </> unEscapeString (normalise subpath)+ let mbcontents = lookupMedia subpath mediabag+ case mbcontents of+ Nothing -> throwError $ PandocResourceNotFound $ T.pack subpath+ Just (_, bs) -> do+ report $ Extracting $ T.pack fullpath+ liftIOError (createDirectoryIfMissing True) (takeDirectory fullpath)+ logIOError $ BL.writeFile fullpath bs++-- | If the given Inline element is an image with a @src@ path equal to+-- one in the list of @paths@, then prepends @dir@ to the image source;+-- returns the element unchanged otherwise.+adjustImagePath :: FilePath -> [FilePath] -> Inline -> Inline+adjustImagePath dir paths (Image attr lab (src, tit))+ | T.unpack src `elem` paths = Image attr lab (T.pack dir <> "/" <> src, tit)+adjustImagePath _ _ x = x
+ src/Text/Pandoc/Class/PandocMonad.hs view
@@ -0,0 +1,699 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE UndecidableInstances #-}+{-# LANGUAGE ViewPatterns #-}+{- |+Module : Text.Pandoc.Class.PandocMonad+Copyright : Copyright (C) 2016-2020 Jesse Rosenthal, John MacFarlane+License : GNU GPL, version 2 or above++Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>+Stability : alpha+Portability : portable++This module defines a type class, 'PandocMonad', for pandoc readers+and writers.+-}++module Text.Pandoc.Class.PandocMonad+ ( PandocMonad(..)+ , getPOSIXTime+ , getZonedTime+ , readFileFromDirs+ , report+ , setTrace+ , setRequestHeader+ , getLog+ , setVerbosity+ , getVerbosity+ , getMediaBag+ , setMediaBag+ , insertMedia+ , setUserDataDir+ , getUserDataDir+ , fetchItem+ , fetchMediaResource+ , getInputFiles+ , setInputFiles+ , getOutputFile+ , setOutputFile+ , setResourcePath+ , getResourcePath+ , readDefaultDataFile+ , readDataFile+ , fillMediaBag+ , toLang+ , setTranslations+ , translateTerm+ , makeCanonical+ ) where++import Codec.Archive.Zip+import Control.Monad.Except (MonadError (catchError, throwError),+ MonadTrans, lift, when)+import Data.Digest.Pure.SHA (sha1, showDigest)+import Data.Maybe (fromMaybe)+import Data.Time (UTCTime)+import Data.Time.Clock.POSIX (POSIXTime, utcTimeToPOSIXSeconds)+import Data.Time.LocalTime (TimeZone, ZonedTime, utcToZonedTime)+import Network.URI ( escapeURIString, nonStrictRelativeTo,+ unEscapeString, parseURIReference, isAllowedInURI,+ parseURI, URI(..) )+import System.FilePath ((</>), (<.>), takeExtension, dropExtension,+ isRelative, splitDirectories)+import System.Random (StdGen)+import Text.Pandoc.BCP47 (Lang(..), parseBCP47, renderLang)+import Text.Pandoc.Class.CommonState (CommonState (..))+import Text.Pandoc.Definition+import Text.Pandoc.Error+import Text.Pandoc.Logging+import Text.Pandoc.MIME (MimeType, getMimeType, extensionFromMimeType)+import Text.Pandoc.MediaBag (MediaBag, lookupMedia)+import Text.Pandoc.Shared (uriPathToPath)+import Text.Pandoc.Translations (Term(..), Translations, lookupTerm,+ readTranslations)+import Text.Pandoc.Walk (walkM)+import Text.Parsec (ParsecT, getPosition, sourceLine, sourceName)+import qualified Data.ByteString as B+import qualified Data.ByteString.Lazy as BL+import qualified Data.Text as T+import qualified Debug.Trace+import qualified System.FilePath.Posix as Posix+import qualified Text.Pandoc.MediaBag as MB+import qualified Text.Pandoc.UTF8 as UTF8+#ifdef EMBED_DATA_FILES+import Text.Pandoc.Data (dataFiles)+#endif++-- | The PandocMonad typeclass contains all the potentially+-- IO-related functions used in pandoc's readers and writers.+-- Instances of this typeclass may implement these functions+-- in IO (as in 'PandocIO') or using an internal state that+-- represents a file system, time, and so on (as in 'PandocPure').+class (Functor m, Applicative m, Monad m, MonadError PandocError m)+ => PandocMonad m where+ -- | Lookup an environment variable.+ lookupEnv :: T.Text -> m (Maybe T.Text)+ -- | Get the current (UTC) time.+ getCurrentTime :: m UTCTime+ -- | Get the locale's time zone.+ getCurrentTimeZone :: m TimeZone+ -- | Return a new generator for random numbers.+ newStdGen :: m StdGen+ -- | Return a new unique integer.+ newUniqueHash :: m Int+ -- | Retrieve contents and mime type from a URL, raising+ -- an error on failure.+ openURL :: T.Text -> m (B.ByteString, Maybe MimeType)+ -- | Read the lazy ByteString contents from a file path,+ -- raising an error on failure.+ readFileLazy :: FilePath -> m BL.ByteString+ -- | Read the strict ByteString contents from a file path,+ -- raising an error on failure.+ readFileStrict :: FilePath -> m B.ByteString+ -- | Return a list of paths that match a glob, relative to+ -- the working directory. See 'System.FilePath.Glob' for+ -- the glob syntax.+ glob :: String -> m [FilePath]+ -- | Returns True if file exists.+ fileExists :: FilePath -> m Bool+ -- | Returns the path of data file.+ getDataFileName :: FilePath -> m FilePath+ -- | Return the modification time of a file.+ getModificationTime :: FilePath -> m UTCTime+ -- | Get the value of the 'CommonState' used by all instances+ -- of 'PandocMonad'.+ getCommonState :: m CommonState+ -- | Set the value of the 'CommonState' used by all instances+ -- of 'PandocMonad'.+ -- | Get the value of a specific field of 'CommonState'.+ putCommonState :: CommonState -> m ()+ -- | Get the value of a specific field of 'CommonState'.+ getsCommonState :: (CommonState -> a) -> m a+ getsCommonState f = f <$> getCommonState+ -- | Modify the 'CommonState'.+ modifyCommonState :: (CommonState -> CommonState) -> m ()+ modifyCommonState f = getCommonState >>= putCommonState . f+ -- | Output a log message.+ logOutput :: LogMessage -> m ()+ -- | Output a debug message to sterr, using 'Debug.Trace.trace',+ -- if tracing is enabled. Note: this writes to stderr even in+ -- pure instances.+ trace :: T.Text -> m ()+ trace msg = do+ tracing <- getsCommonState stTrace+ when tracing $ Debug.Trace.trace ("[trace] " ++ T.unpack msg) (return ())++-- * Functions defined for all PandocMonad instances++-- | Set the verbosity level.+setVerbosity :: PandocMonad m => Verbosity -> m ()+setVerbosity verbosity =+ modifyCommonState $ \st -> st{ stVerbosity = verbosity }++-- | Get the verbosity level.+getVerbosity :: PandocMonad m => m Verbosity+getVerbosity = getsCommonState stVerbosity++-- | Get the accomulated log messages (in temporal order).+getLog :: PandocMonad m => m [LogMessage]+getLog = reverse <$> getsCommonState stLog++-- | Log a message using 'logOutput'. Note that 'logOutput' is+-- called only if the verbosity level exceeds the level of the+-- message, but the message is added to the list of log messages+-- that will be retrieved by 'getLog' regardless of its verbosity level.+report :: PandocMonad m => LogMessage -> m ()+report msg = do+ verbosity <- getsCommonState stVerbosity+ let level = messageVerbosity msg+ when (level <= verbosity) $ logOutput msg+ modifyCommonState $ \st -> st{ stLog = msg : stLog st }++-- | Determine whether tracing is enabled. This affects+-- the behavior of 'trace'. If tracing is not enabled,+-- 'trace' does nothing.+setTrace :: PandocMonad m => Bool -> m ()+setTrace useTracing = modifyCommonState $ \st -> st{stTrace = useTracing}++-- | Set request header to use in HTTP requests.+setRequestHeader :: PandocMonad m+ => T.Text -- ^ Header name+ -> T.Text -- ^ Value+ -> m ()+setRequestHeader name val = modifyCommonState $ \st ->+ st{ stRequestHeaders =+ (name, val) : filter (\(n,_) -> n /= name) (stRequestHeaders st) }++-- | Initialize the media bag.+setMediaBag :: PandocMonad m => MediaBag -> m ()+setMediaBag mb = modifyCommonState $ \st -> st{stMediaBag = mb}++-- | Retrieve the media bag.+getMediaBag :: PandocMonad m => m MediaBag+getMediaBag = getsCommonState stMediaBag++-- | Insert an item into the media bag.+insertMedia :: PandocMonad m => FilePath -> Maybe MimeType -> BL.ByteString -> m ()+insertMedia fp mime bs = do+ mb <- getMediaBag+ let mb' = MB.insertMedia fp mime bs mb+ setMediaBag mb'++-- | Retrieve the input filenames.+getInputFiles :: PandocMonad m => m [FilePath]+getInputFiles = getsCommonState stInputFiles++-- | Set the input filenames.+setInputFiles :: PandocMonad m => [FilePath] -> m ()+setInputFiles fs = do+ let sourceURL = case fs of+ [] -> Nothing+ (x:_) -> case parseURI x of+ Just u+ | uriScheme u `elem` ["http:","https:"] ->+ Just $ show u{ uriQuery = "",+ uriFragment = "" }+ _ -> Nothing++ modifyCommonState $ \st -> st{ stInputFiles = fs+ , stSourceURL = T.pack <$> sourceURL }++-- | Retrieve the output filename.+getOutputFile :: PandocMonad m => m (Maybe FilePath)+getOutputFile = getsCommonState stOutputFile++-- | Set the output filename.+setOutputFile :: PandocMonad m => Maybe FilePath -> m ()+setOutputFile mbf = modifyCommonState $ \st -> st{ stOutputFile = mbf }++-- | Retrieve the resource path searched by 'fetchItem'.+getResourcePath :: PandocMonad m => m [FilePath]+getResourcePath = getsCommonState stResourcePath++-- | Set the resource path searched by 'fetchItem'.+setResourcePath :: PandocMonad m => [FilePath] -> m ()+setResourcePath ps = modifyCommonState $ \st -> st{stResourcePath = ps}++-- | Get the POSIX time.+getPOSIXTime :: PandocMonad m => m POSIXTime+getPOSIXTime = utcTimeToPOSIXSeconds <$> getCurrentTime++-- | Get the zoned time.+getZonedTime :: PandocMonad m => m ZonedTime+getZonedTime = do+ t <- getCurrentTime+ tz <- getCurrentTimeZone+ return $ utcToZonedTime tz t++-- | Read file, checking in any number of directories.+readFileFromDirs :: PandocMonad m => [FilePath] -> FilePath -> m (Maybe T.Text)+readFileFromDirs [] _ = return Nothing+readFileFromDirs (d:ds) f = catchError+ (Just . T.pack . UTF8.toStringLazy <$> readFileLazy (d </> f))+ (\_ -> readFileFromDirs ds f)++-- | Convert BCP47 string to a Lang, issuing warning+-- if there are problems.+toLang :: PandocMonad m => Maybe T.Text -> m (Maybe Lang)+toLang Nothing = return Nothing+toLang (Just s) =+ case parseBCP47 s of+ Left _ -> do+ report $ InvalidLang s+ return Nothing+ Right l -> return (Just l)++-- | Select the language to use with 'translateTerm'.+-- Note that this does not read a translation file;+-- that is only done the first time 'translateTerm' is+-- used.+setTranslations :: PandocMonad m => Lang -> m ()+setTranslations lang =+ modifyCommonState $ \st -> st{ stTranslations = Just (lang, Nothing) }++-- | Load term map.+getTranslations :: PandocMonad m => m Translations+getTranslations = do+ mbtrans <- getsCommonState stTranslations+ case mbtrans of+ Nothing -> return mempty -- no language defined+ Just (_, Just t) -> return t+ Just (lang, Nothing) -> do -- read from file+ let translationFile = "translations/" <> renderLang lang <> ".yaml"+ let fallbackFile = "translations/" <> langLanguage lang <> ".yaml"+ let getTrans fp = do+ bs <- readDataFile fp+ case readTranslations (UTF8.toText bs) of+ Left e -> do+ report $ CouldNotLoadTranslations (renderLang lang)+ (T.pack fp <> ": " <> e)+ -- make sure we don't try again...+ modifyCommonState $ \st ->+ st{ stTranslations = Nothing }+ return mempty+ Right t -> do+ modifyCommonState $ \st ->+ st{ stTranslations = Just (lang, Just t) }+ return t+ catchError (getTrans $ T.unpack translationFile)+ (\_ ->+ catchError (getTrans $ T.unpack fallbackFile)+ (\e -> do+ report $ CouldNotLoadTranslations (renderLang lang)+ $ case e of+ PandocCouldNotFindDataFileError _ ->+ "data file " <> fallbackFile <> " not found"+ _ -> ""+ -- make sure we don't try again...+ modifyCommonState $ \st -> st{ stTranslations = Nothing }+ return mempty))++-- | Get a translation from the current term map.+-- Issue a warning if the term is not defined.+translateTerm :: PandocMonad m => Term -> m T.Text+translateTerm term = do+ translations <- getTranslations+ case lookupTerm term translations of+ Just s -> return s+ Nothing -> do+ report $ NoTranslation $ T.pack $ show term+ return ""++-- | Specialized version of parseURIReference that disallows+-- single-letter schemes. Reason: these are usually windows absolute+-- paths.+parseURIReference' :: T.Text -> Maybe URI+parseURIReference' s = do+ u <- parseURIReference (T.unpack s)+ case uriScheme u of+ [_] -> Nothing+ _ -> Just u++-- | Set the user data directory in common state.+setUserDataDir :: PandocMonad m+ => Maybe FilePath+ -> m ()+setUserDataDir mbfp = modifyCommonState $ \st -> st{ stUserDataDir = mbfp }++-- | Get the user data directory from common state.+getUserDataDir :: PandocMonad m+ => m (Maybe FilePath)+getUserDataDir = getsCommonState stUserDataDir++-- | Fetch an image or other item from the local filesystem or the net.+-- Returns raw content and maybe mime type.+fetchItem :: PandocMonad m+ => T.Text+ -> m (B.ByteString, Maybe MimeType)+fetchItem s = do+ mediabag <- getMediaBag+ case lookupMedia (T.unpack s) mediabag of+ Just (mime, bs) -> return (BL.toStrict bs, Just mime)+ Nothing -> downloadOrRead s++-- | Returns the content and, if available, the MIME type of a resource.+-- If the given resource location is a valid URI, then download the+-- resource from that URI. Otherwise, treat the resource identifier as a+-- local file name.+--+-- Note that resources are treated relative to the URL of the first+-- input source, if any.+downloadOrRead :: PandocMonad m+ => T.Text+ -> m (B.ByteString, Maybe MimeType)+downloadOrRead s = do+ sourceURL <- getsCommonState stSourceURL+ case (sourceURL >>= parseURIReference' .+ ensureEscaped, ensureEscaped s) of+ (Just u, s') -> -- try fetching from relative path at source+ case parseURIReference' s' of+ Just u' -> openURL $ T.pack $ show $ u' `nonStrictRelativeTo` u+ Nothing -> openURL s' -- will throw error+ (Nothing, s'@(T.unpack -> ('/':'/':c:_))) | c /= '?' -> -- protocol-relative URI+ -- we exclude //? because of //?UNC/ on Windows+ case parseURIReference' s' of+ Just u' -> openURL $ T.pack $ show $ u' `nonStrictRelativeTo` httpcolon+ Nothing -> openURL s' -- will throw error+ (Nothing, s') ->+ case parseURI (T.unpack s') of -- requires absolute URI+ Just u' | uriScheme u' == "file:" ->+ readLocalFile $ uriPathToPath (T.pack $ uriPath u')+ -- We don't want to treat C:/ as a scheme:+ Just u' | length (uriScheme u') > 2 -> openURL (T.pack $ show u')+ _ -> readLocalFile fp -- get from local file system+ where readLocalFile f = do+ resourcePath <- getResourcePath+ cont <- if isRelative f+ then withPaths resourcePath readFileStrict f+ else readFileStrict f+ return (cont, mime)+ httpcolon = URI{ uriScheme = "http:",+ uriAuthority = Nothing,+ uriPath = "",+ uriQuery = "",+ uriFragment = "" }+ dropFragmentAndQuery = T.takeWhile (\c -> c /= '?' && c /= '#')+ fp = unEscapeString $ T.unpack $ dropFragmentAndQuery s+ mime = getMimeType $ case takeExtension fp of+ ".gz" -> dropExtension fp+ ".svgz" -> dropExtension fp ++ ".svg"+ x -> x+ ensureEscaped = T.pack . escapeURIString isAllowedInURI . T.unpack . T.map convertSlash+ convertSlash '\\' = '/'+ convertSlash x = x++-- | Retrieve default reference.docx.+getDefaultReferenceDocx :: PandocMonad m => m Archive+getDefaultReferenceDocx = do+ let paths = ["[Content_Types].xml",+ "_rels/.rels",+ "docProps/app.xml",+ "docProps/core.xml",+ "docProps/custom.xml",+ "word/document.xml",+ "word/fontTable.xml",+ "word/footnotes.xml",+ "word/comments.xml",+ "word/numbering.xml",+ "word/settings.xml",+ "word/webSettings.xml",+ "word/styles.xml",+ "word/_rels/document.xml.rels",+ "word/_rels/footnotes.xml.rels",+ "word/theme/theme1.xml"]+ let toLazy = BL.fromChunks . (:[])+ let pathToEntry path = do+ epochtime <- (floor . utcTimeToPOSIXSeconds) <$> getCurrentTime+ contents <- toLazy <$> readDataFile ("docx/" ++ path)+ return $ toEntry path epochtime contents+ datadir <- getUserDataDir+ mbArchive <- case datadir of+ Nothing -> return Nothing+ Just d -> do+ exists <- fileExists (d </> "reference.docx")+ if exists+ then return (Just (d </> "reference.docx"))+ else return Nothing+ case mbArchive of+ Just arch -> toArchive <$> readFileLazy arch+ Nothing -> foldr addEntryToArchive emptyArchive <$>+ mapM pathToEntry paths++-- | Retrieve default reference.odt.+getDefaultReferenceODT :: PandocMonad m => m Archive+getDefaultReferenceODT = do+ let paths = ["mimetype",+ "manifest.rdf",+ "styles.xml",+ "content.xml",+ "meta.xml",+ "settings.xml",+ "Configurations2/accelerator/current.xml",+ "Thumbnails/thumbnail.png",+ "META-INF/manifest.xml"]+ let pathToEntry path = do epochtime <- floor `fmap` getPOSIXTime+ contents <- (BL.fromChunks . (:[])) `fmap`+ readDataFile ("odt/" ++ path)+ return $ toEntry path epochtime contents+ datadir <- getUserDataDir+ mbArchive <- case datadir of+ Nothing -> return Nothing+ Just d -> do+ exists <- fileExists (d </> "reference.odt")+ if exists+ then return (Just (d </> "reference.odt"))+ else return Nothing+ case mbArchive of+ Just arch -> toArchive <$> readFileLazy arch+ Nothing -> foldr addEntryToArchive emptyArchive <$>+ mapM pathToEntry paths++-- | Retrieve default reference.pptx.+getDefaultReferencePptx :: PandocMonad m => m Archive+getDefaultReferencePptx = do+ -- We're going to narrow this down substantially once we get it+ -- working.+ let paths = [ "[Content_Types].xml"+ , "_rels/.rels"+ , "docProps/app.xml"+ , "docProps/core.xml"+ , "ppt/_rels/presentation.xml.rels"+ , "ppt/presProps.xml"+ , "ppt/presentation.xml"+ , "ppt/slideLayouts/_rels/slideLayout1.xml.rels"+ , "ppt/slideLayouts/_rels/slideLayout2.xml.rels"+ , "ppt/slideLayouts/_rels/slideLayout3.xml.rels"+ , "ppt/slideLayouts/_rels/slideLayout4.xml.rels"+ , "ppt/slideLayouts/_rels/slideLayout5.xml.rels"+ , "ppt/slideLayouts/_rels/slideLayout6.xml.rels"+ , "ppt/slideLayouts/_rels/slideLayout7.xml.rels"+ , "ppt/slideLayouts/_rels/slideLayout8.xml.rels"+ , "ppt/slideLayouts/_rels/slideLayout9.xml.rels"+ , "ppt/slideLayouts/_rels/slideLayout10.xml.rels"+ , "ppt/slideLayouts/_rels/slideLayout11.xml.rels"+ , "ppt/slideLayouts/slideLayout1.xml"+ , "ppt/slideLayouts/slideLayout10.xml"+ , "ppt/slideLayouts/slideLayout11.xml"+ , "ppt/slideLayouts/slideLayout2.xml"+ , "ppt/slideLayouts/slideLayout3.xml"+ , "ppt/slideLayouts/slideLayout4.xml"+ , "ppt/slideLayouts/slideLayout5.xml"+ , "ppt/slideLayouts/slideLayout6.xml"+ , "ppt/slideLayouts/slideLayout7.xml"+ , "ppt/slideLayouts/slideLayout8.xml"+ , "ppt/slideLayouts/slideLayout9.xml"+ , "ppt/slideMasters/_rels/slideMaster1.xml.rels"+ , "ppt/slideMasters/slideMaster1.xml"+ , "ppt/slides/_rels/slide1.xml.rels"+ , "ppt/slides/slide1.xml"+ , "ppt/slides/_rels/slide2.xml.rels"+ , "ppt/slides/slide2.xml"+ , "ppt/slides/_rels/slide3.xml.rels"+ , "ppt/slides/slide3.xml"+ , "ppt/slides/_rels/slide4.xml.rels"+ , "ppt/slides/slide4.xml"+ , "ppt/tableStyles.xml"+ , "ppt/theme/theme1.xml"+ , "ppt/viewProps.xml"+ -- These relate to notes slides.+ , "ppt/notesMasters/notesMaster1.xml"+ , "ppt/notesMasters/_rels/notesMaster1.xml.rels"+ , "ppt/notesSlides/notesSlide1.xml"+ , "ppt/notesSlides/_rels/notesSlide1.xml.rels"+ , "ppt/notesSlides/notesSlide2.xml"+ , "ppt/notesSlides/_rels/notesSlide2.xml.rels"+ , "ppt/theme/theme2.xml"+ ]+ let toLazy = BL.fromChunks . (:[])+ let pathToEntry path = do+ epochtime <- (floor . utcTimeToPOSIXSeconds) <$> getCurrentTime+ contents <- toLazy <$> readDataFile ("pptx/" ++ path)+ return $ toEntry path epochtime contents+ datadir <- getUserDataDir+ mbArchive <- case datadir of+ Nothing -> return Nothing+ Just d -> do+ exists <- fileExists (d </> "reference.pptx")+ if exists+ then return (Just (d </> "reference.pptx"))+ else return Nothing+ case mbArchive of+ Just arch -> toArchive <$> readFileLazy arch+ Nothing -> foldr addEntryToArchive emptyArchive <$>+ mapM pathToEntry paths++-- | Read file from user data directory or,+-- if not found there, from Cabal data directory.+readDataFile :: PandocMonad m => FilePath -> m B.ByteString+readDataFile fname = do+ datadir <- getUserDataDir+ case datadir of+ Nothing -> readDefaultDataFile fname+ Just userDir -> do+ exists <- fileExists (userDir </> fname)+ if exists+ then readFileStrict (userDir </> fname)+ else readDefaultDataFile fname++-- | Read file from from Cabal data directory.+readDefaultDataFile :: PandocMonad m => FilePath -> m B.ByteString+readDefaultDataFile "reference.docx" =+ (B.concat . BL.toChunks . fromArchive) <$> getDefaultReferenceDocx+readDefaultDataFile "reference.pptx" =+ (B.concat . BL.toChunks . fromArchive) <$> getDefaultReferencePptx+readDefaultDataFile "reference.odt" =+ (B.concat . BL.toChunks . fromArchive) <$> getDefaultReferenceODT+readDefaultDataFile fname =+#ifdef EMBED_DATA_FILES+ case lookup (makeCanonical fname) dataFiles of+ Nothing -> throwError $ PandocCouldNotFindDataFileError $ T.pack fname+ Just contents -> return contents+#else+ getDataFileName fname' >>= checkExistence >>= readFileStrict+ where fname' = if fname == "MANUAL.txt" then fname else "data" </> fname++-- | Returns the input filename unchanged if the file exits, and throws+-- a `PandocCouldNotFindDataFileError` if it doesn't.+checkExistence :: PandocMonad m => FilePath -> m FilePath+checkExistence fn = do+ exists <- fileExists fn+ if exists+ then return fn+ else throwError $ PandocCouldNotFindDataFileError $ T.pack fn+#endif++-- | Canonicalizes a file path by removing redundant @.@ and @..@.+makeCanonical :: FilePath -> FilePath+makeCanonical = Posix.joinPath . transformPathParts . splitDirectories+ where transformPathParts = reverse . foldl go []+ go as "." = as+ go (_:as) ".." = as+ go as x = x : as++-- | Trys to run an action on a file: for each directory given, a+-- filepath is created from the given filename, and the action is run on+-- that filepath. Returns the result of the first successful execution+-- of the action, or throws a @PandocResourceNotFound@ exception if the+-- action errors for all filepaths.+withPaths :: PandocMonad m => [FilePath] -> (FilePath -> m a) -> FilePath -> m a+withPaths [] _ fp = throwError $ PandocResourceNotFound $ T.pack fp+withPaths (p:ps) action fp =+ catchError (action (p </> fp))+ (\_ -> withPaths ps action fp)++-- | Fetch local or remote resource (like an image) and provide data suitable+-- for adding it to the MediaBag.+fetchMediaResource :: PandocMonad m+ => T.Text -> m (FilePath, Maybe MimeType, BL.ByteString)+fetchMediaResource src = do+ (bs, mt) <- downloadOrRead src+ let ext = fromMaybe (T.pack $ takeExtension $ T.unpack src)+ (mt >>= extensionFromMimeType)+ let bs' = BL.fromChunks [bs]+ let basename = showDigest $ sha1 bs'+ let fname = basename <.> T.unpack ext+ return (fname, mt, bs')++-- | Traverse tree, filling media bag for any images that+-- aren't already in the media bag.+fillMediaBag :: PandocMonad m => Pandoc -> m Pandoc+fillMediaBag d = walkM handleImage d+ where handleImage :: PandocMonad m => Inline -> m Inline+ handleImage (Image attr lab (src, tit)) = catchError+ (do mediabag <- getMediaBag+ case lookupMedia (T.unpack src) mediabag of+ Just (_, _) -> return $ Image attr lab (src, tit)+ Nothing -> do+ (fname, mt, bs) <- fetchMediaResource src+ insertMedia fname mt bs+ return $ Image attr lab (T.pack fname, tit))+ (\e ->+ case e of+ PandocResourceNotFound _ -> do+ report $ CouldNotFetchResource src+ "replacing image with description"+ -- emit alt text+ return $ Span ("",["image"],[]) lab+ PandocHttpError u er -> do+ report $ CouldNotFetchResource u+ (T.pack $ show er ++ "\rReplacing image with description.")+ -- emit alt text+ return $ Span ("",["image"],[]) lab+ _ -> throwError e)+ handleImage x = return x++-- This requires UndecidableInstances. We could avoid that+-- by repeating the definitions below for every monad transformer+-- we use: ReaderT, WriterT, StateT, RWST. But this seems to+-- be harmless.+instance (MonadTrans t, PandocMonad m, Functor (t m),+ MonadError PandocError (t m), Monad (t m),+ Applicative (t m)) => PandocMonad (t m) where+ lookupEnv = lift . lookupEnv+ getCurrentTime = lift getCurrentTime+ getCurrentTimeZone = lift getCurrentTimeZone+ newStdGen = lift newStdGen+ newUniqueHash = lift newUniqueHash+ openURL = lift . openURL+ readFileLazy = lift . readFileLazy+ readFileStrict = lift . readFileStrict+ glob = lift . glob+ fileExists = lift . fileExists+ getDataFileName = lift . getDataFileName+ getModificationTime = lift . getModificationTime+ getCommonState = lift getCommonState+ putCommonState = lift . putCommonState+ logOutput = lift . logOutput++instance {-# OVERLAPS #-} PandocMonad m => PandocMonad (ParsecT s st m) where+ lookupEnv = lift . lookupEnv+ getCurrentTime = lift getCurrentTime+ getCurrentTimeZone = lift getCurrentTimeZone+ newStdGen = lift newStdGen+ newUniqueHash = lift newUniqueHash+ openURL = lift . openURL+ readFileLazy = lift . readFileLazy+ readFileStrict = lift . readFileStrict+ glob = lift . glob+ fileExists = lift . fileExists+ getDataFileName = lift . getDataFileName+ getModificationTime = lift . getModificationTime+ getCommonState = lift getCommonState+ putCommonState = lift . putCommonState+ trace msg = do+ tracing <- getsCommonState stTrace+ when tracing $ do+ pos <- getPosition+ Debug.Trace.trace+ ("[trace] Parsed " ++ T.unpack msg ++ " at line " +++ show (sourceLine pos) +++ if sourceName pos == "chunk"+ then " of chunk"+ else "")+ (return ())+ logOutput = lift . logOutput
+ src/Text/Pandoc/Class/PandocPure.hs view
@@ -0,0 +1,218 @@+{-# LANGUAGE DeriveFunctor #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE OverloadedStrings #-}+{- |+Module : Text.Pandoc.Class.PandocPure+Copyright : Copyright (C) 2016-2020 Jesse Rosenthal, John MacFarlane+License : GNU GPL, version 2 or above++Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>+Stability : alpha+Portability : portable++This module defines a pure instance 'PandocPure' of the @'PandocMonad'@+typeclass. This instance is useful for testing, or when all IO access is+prohibited for security reasons.+-}+module Text.Pandoc.Class.PandocPure+ ( PureState(..)+ , getPureState+ , getsPureState+ , putPureState+ , modifyPureState+ , PandocPure(..)+ , FileTree+ , FileInfo(..)+ , addToFileTree+ , insertInFileTree+ , runPure+ ) where++import Codec.Archive.Zip+import Control.Monad.Except+import Control.Monad.State.Strict+import Data.Default+import Data.Text (Text)+import Data.Time (UTCTime)+import Data.Time.Clock.POSIX ( posixSecondsToUTCTime )+import Data.Time.LocalTime (TimeZone, utc)+import Data.Word (Word8)+import System.Directory (doesDirectoryExist, getDirectoryContents)+import System.FilePath ((</>))+import System.FilePath.Glob (match, compile)+import System.Random (StdGen, next, mkStdGen)+import Text.Pandoc.Class.CommonState (CommonState (..))+import Text.Pandoc.Class.PandocMonad+import Text.Pandoc.Error+import qualified Data.ByteString as B+import qualified Data.ByteString.Lazy as BL+import qualified Data.Map as M+import qualified Data.Text as T+import qualified System.Directory as Directory (getModificationTime)++-- | The 'PureState' contains ersatz representations+-- of things that would normally be obtained through IO.+data PureState = PureState+ { stStdGen :: StdGen+ , stWord8Store :: [Word8] -- ^ should be infinite, i.e. [1..]+ , stUniqStore :: [Int] -- ^ should be infinite and contain every+ -- element at most once, e.g. [1..]+ , stEnv :: [(Text, Text)]+ , stTime :: UTCTime+ , stTimeZone :: TimeZone+ , stReferenceDocx :: Archive+ , stReferencePptx :: Archive+ , stReferenceODT :: Archive+ , stFiles :: FileTree+ , stUserDataFiles :: FileTree+ , stCabalDataFiles :: FileTree+ }++instance Default PureState where+ def = PureState+ { stStdGen = mkStdGen 1848+ , stWord8Store = [1..]+ , stUniqStore = [1..]+ , stEnv = [("USER", "pandoc-user")]+ , stTime = posixSecondsToUTCTime 0+ , stTimeZone = utc+ , stReferenceDocx = emptyArchive+ , stReferencePptx = emptyArchive+ , stReferenceODT = emptyArchive+ , stFiles = mempty+ , stUserDataFiles = mempty+ , stCabalDataFiles = mempty+ }+++-- | Retrieve the underlying state of the @'PandocPure'@ type.+getPureState :: PandocPure PureState+getPureState = PandocPure $ lift $ lift get++-- | Retrieve a value from the underlying state of the @'PandocPure'@+-- type.+getsPureState :: (PureState -> a) -> PandocPure a+getsPureState f = f <$> getPureState++-- | Set a new state for the @'PandocPure'@ type.+putPureState :: PureState -> PandocPure ()+putPureState ps= PandocPure $ lift $ lift $ put ps++-- | Modify the underlying state of the @'PandocPure'@ type.+modifyPureState :: (PureState -> PureState) -> PandocPure ()+modifyPureState f = PandocPure $ lift $ lift $ modify f++-- | Captures all file-level information necessary for a @'PandocMonad'@+-- conforming mock file system.+data FileInfo = FileInfo+ { infoFileMTime :: UTCTime+ , infoFileContents :: B.ByteString+ }++-- | Basis of the mock file system used by @'PandocPure'@.+newtype FileTree = FileTree { unFileTree :: M.Map FilePath FileInfo }+ deriving (Semigroup, Monoid)++-- | Retrieve @'FileInfo'@ of the given @'FilePath'@ from a+-- @'FileTree'@.+getFileInfo :: FilePath -> FileTree -> Maybe FileInfo+getFileInfo fp tree =+ M.lookup (makeCanonical fp) (unFileTree tree)++-- | Add the specified file to the FileTree. If file+-- is a directory, add its contents recursively.+addToFileTree :: FileTree -> FilePath -> IO FileTree+addToFileTree tree fp = do+ isdir <- doesDirectoryExist fp+ if isdir+ then do -- recursively add contents of directories+ let isSpecial ".." = True+ isSpecial "." = True+ isSpecial _ = False+ fs <- map (fp </>) . filter (not . isSpecial) <$> getDirectoryContents fp+ foldM addToFileTree tree fs+ else do+ contents <- B.readFile fp+ mtime <- Directory.getModificationTime fp+ return $ insertInFileTree fp FileInfo{ infoFileMTime = mtime+ , infoFileContents = contents } tree++-- | Insert an ersatz file into the 'FileTree'.+insertInFileTree :: FilePath -> FileInfo -> FileTree -> FileTree+insertInFileTree fp info (FileTree treemap) =+ FileTree $ M.insert (makeCanonical fp) info treemap++newtype PandocPure a = PandocPure {+ unPandocPure :: ExceptT PandocError+ (StateT CommonState (State PureState)) a+ } deriving ( Functor+ , Applicative+ , Monad+ , MonadError PandocError+ )++-- | Run a 'PandocPure' operation.+runPure :: PandocPure a -> Either PandocError a+runPure x = flip evalState def $+ flip evalStateT def $+ runExceptT $+ unPandocPure x++instance PandocMonad PandocPure where+ lookupEnv s = do+ env <- getsPureState stEnv+ return (lookup s env)++ getCurrentTime = getsPureState stTime++ getCurrentTimeZone = getsPureState stTimeZone++ newStdGen = do+ g <- getsPureState stStdGen+ let (_, nxtGen) = next g+ modifyPureState $ \st -> st { stStdGen = nxtGen }+ return g++ newUniqueHash = do+ uniqs <- getsPureState stUniqStore+ case uniqs of+ u : us -> do+ modifyPureState $ \st -> st { stUniqStore = us }+ return u+ _ -> throwError $ PandocShouldNeverHappenError+ "uniq store ran out of elements"+ openURL u = throwError $ PandocResourceNotFound u+ readFileLazy fp = do+ fps <- getsPureState stFiles+ case infoFileContents <$> getFileInfo fp fps of+ Just bs -> return (BL.fromStrict bs)+ Nothing -> throwError $ PandocResourceNotFound $ T.pack fp+ readFileStrict fp = do+ fps <- getsPureState stFiles+ case infoFileContents <$> getFileInfo fp fps of+ Just bs -> return bs+ Nothing -> throwError $ PandocResourceNotFound $ T.pack fp++ glob s = do+ FileTree ftmap <- getsPureState stFiles+ return $ filter (match (compile s)) $ M.keys ftmap++ fileExists fp = do+ fps <- getsPureState stFiles+ case getFileInfo fp fps of+ Nothing -> return False+ Just _ -> return True++ getDataFileName fp = return $ "data/" ++ fp++ getModificationTime fp = do+ fps <- getsPureState stFiles+ case infoFileMTime <$> getFileInfo fp fps of+ Just tm -> return tm+ Nothing -> throwError $ PandocIOError (T.pack fp)+ (userError "Can't get modification time")++ getCommonState = PandocPure $ lift get+ putCommonState x = PandocPure $ lift $ put x++ logOutput _msg = return ()
src/Text/Pandoc/Data.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE TemplateHaskell #-} {- | Module : Text.Pandoc.Data-Copyright : Copyright (C) 2013-2019 John MacFarlane+Copyright : Copyright (C) 2013-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley@edu>@@ -13,7 +12,6 @@ -} module Text.Pandoc.Data (dataFiles) where -import Prelude import qualified Data.ByteString as B import Data.FileEmbed import System.FilePath (splitDirectories)
src/Text/Pandoc/Emoji.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Emoji@@ -12,7 +11,6 @@ Emoji symbol lookup from canonical string identifier. -} module Text.Pandoc.Emoji ( emojis, emojiToInline ) where-import Prelude import qualified Text.Emoji as E import Text.Pandoc.Definition (Inline (Span, Str)) import Data.Text (Text)
src/Text/Pandoc/Error.hs view
@@ -1,10 +1,9 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Error- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -19,7 +18,6 @@ PandocError(..), handleError) where -import Prelude import Control.Exception (Exception) import Data.Typeable (Typeable) import Data.Word (Word8)
src/Text/Pandoc/Extensions.hs view
@@ -1,5 +1,4 @@ {-# LANGUAGE CPP #-}-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}@@ -7,7 +6,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Extensions- Copyright : Copyright (C) 2012-2019 John MacFarlane+ Copyright : Copyright (C) 2012-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -33,7 +32,6 @@ , githubMarkdownExtensions , multimarkdownExtensions ) where-import Prelude import Data.Bits (clearBit, setBit, testBit, (.|.)) import Data.Data (Data) import qualified Data.Text as T
src/Text/Pandoc/Filter.hs view
@@ -1,11 +1,10 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Filter- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley@edu>@@ -19,11 +18,11 @@ , applyFilters ) where -import Prelude import System.CPUTime (getCPUTime) import Data.Aeson.TH (deriveJSON, defaultOptions) import GHC.Generics (Generic)-import Text.Pandoc.Class (PandocIO, report, getVerbosity)+import Text.Pandoc.Class.PandocIO (PandocIO)+import Text.Pandoc.Class.PandocMonad (report, getVerbosity) import Text.Pandoc.Definition (Pandoc) import Text.Pandoc.Options (ReaderOptions) import Text.Pandoc.Logging
src/Text/Pandoc/Filter/JSON.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Filter- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley@edu>@@ -13,7 +12,6 @@ -} module Text.Pandoc.Filter.JSON (apply) where -import Prelude import Control.Monad (unless, when) import Control.Monad.Trans (MonadIO (liftIO)) import Data.Aeson (eitherDecode', encode)@@ -25,7 +23,7 @@ import System.Environment (getEnvironment) import System.Exit (ExitCode (..)) import System.FilePath ((</>), takeExtension)-import Text.Pandoc.Class (PandocIO)+import Text.Pandoc.Class.PandocIO (PandocIO) import Text.Pandoc.Error (PandocError (PandocFilterError)) import Text.Pandoc.Definition (Pandoc) import Text.Pandoc.Options (ReaderOptions)
src/Text/Pandoc/Filter/Lua.hs view
@@ -1,7 +1,6 @@-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.Filter.Lua- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley@edu>@@ -12,11 +11,10 @@ -} module Text.Pandoc.Filter.Lua (apply) where -import Prelude import Control.Exception (throw) import Control.Monad ((>=>)) import qualified Data.Text as T-import Text.Pandoc.Class (PandocIO)+import Text.Pandoc.Class.PandocIO (PandocIO) import Text.Pandoc.Definition (Pandoc) import Text.Pandoc.Error (PandocError (PandocFilterError)) import Text.Pandoc.Lua (Global (..), LuaException (..),
src/Text/Pandoc/Filter/Path.hs view
@@ -1,7 +1,6 @@-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.Filter.Path- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley@edu>@@ -14,8 +13,7 @@ ( expandFilterPath ) where -import Prelude-import Text.Pandoc.Class (PandocMonad, fileExists, getUserDataDir)+import Text.Pandoc.Class.PandocMonad (PandocMonad, fileExists, getUserDataDir) import System.FilePath ((</>), isRelative) -- First we check to see if a filter is found. If not, and if it's
src/Text/Pandoc/Highlighting.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Highlighting- Copyright : Copyright (C) 2008-2019 John MacFarlane+ Copyright : Copyright (C) 2008-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -34,7 +33,6 @@ , fromListingsLanguage , toListingsLanguage ) where-import Prelude import Control.Monad import qualified Data.Map as M import Data.Maybe (fromMaybe)
src/Text/Pandoc/Image.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings, ScopedTypeVariables, CPP #-} {-# LANGUAGE ViewPatterns #-} {- |@@ -13,7 +12,6 @@ Functions for converting images. -} module Text.Pandoc.Image ( svgToPng ) where-import Prelude import Text.Pandoc.Options (WriterOptions(..)) import Text.Pandoc.Process (pipeProcess) import qualified Data.ByteString.Lazy as L
src/Text/Pandoc/ImageSize.hs view
@@ -1,10 +1,9 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings, ScopedTypeVariables, CPP #-} {-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -fno-warn-type-defaults #-} {- | Module : Text.Pandoc.ImageSize-Copyright : Copyright (C) 2011-2019 John MacFarlane+Copyright : Copyright (C) 2011-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -33,7 +32,6 @@ , showInPixel , showFl ) where-import Prelude import Data.ByteString (ByteString, unpack) import qualified Data.ByteString.Char8 as B import qualified Data.ByteString.Lazy as BL
src/Text/Pandoc/Logging.hs view
@@ -1,10 +1,9 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Logging- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -23,7 +22,6 @@ , messageVerbosity ) where -import Prelude import Control.Monad (mzero) import Data.YAML (withStr, FromYAML(..)) import Data.Aeson
src/Text/Pandoc/Lua.hs view
@@ -1,7 +1,6 @@-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.Lua- Copyright : Copyright © 2017–2019 Albert Krewinkel+ Copyright : Copyright © 2017–2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
src/Text/Pandoc/Lua/Filter.hs view
@@ -1,5 +1,4 @@ {-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.Lua.Filter Copyright : © 2012–2020 John MacFarlane,@@ -17,7 +16,6 @@ , walkBlocks , module Text.Pandoc.Lua.Walk ) where-import Prelude import Control.Applicative ((<|>)) import Control.Monad (mplus, (>=>)) import Control.Monad.Catch (finally)
src/Text/Pandoc/Lua/Global.hs view
@@ -1,8 +1,7 @@ {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.Lua- Copyright : Copyright © 2017-2019 Albert Krewinkel+ Copyright : Copyright © 2017-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -15,13 +14,12 @@ , setGlobals ) where -import Prelude import Data.Data (Data) import Foreign.Lua (Lua, Peekable, Pushable) import Foreign.Lua.Userdata ( ensureUserdataMetatable, pushAnyWithMetatable , metatableName) import Paths_pandoc (version)-import Text.Pandoc.Class (CommonState)+import Text.Pandoc.Class.CommonState (CommonState) import Text.Pandoc.Definition (Pandoc (Pandoc), pandocTypesVersion) import Text.Pandoc.Lua.Marshaling () import Text.Pandoc.Lua.Util (addFunction)
src/Text/Pandoc/Lua/Init.hs view
@@ -1,7 +1,6 @@-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.Lua- Copyright : Copyright © 2017-2019 Albert Krewinkel+ Copyright : Copyright © 2017-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -16,13 +15,13 @@ , luaPackageParams ) where -import Prelude import Control.Monad.Trans (MonadIO (..)) import Data.Data (Data, dataTypeConstrs, dataTypeOf, showConstr) import Foreign.Lua (Lua) import GHC.IO.Encoding (getForeignEncoding, setForeignEncoding, utf8)-import Text.Pandoc.Class (PandocIO, getCommonState, getUserDataDir,- putCommonState)+import Text.Pandoc.Class.PandocIO (PandocIO)+import Text.Pandoc.Class.PandocMonad (getCommonState, getUserDataDir,+ putCommonState) import Text.Pandoc.Lua.Global (Global (..), setGlobals) import Text.Pandoc.Lua.Packages (LuaPackageParams (..), installPandocPackageSearcher)
src/Text/Pandoc/Lua/Marshaling.hs view
@@ -1,7 +1,7 @@ {- | Module : Text.Pandoc.Lua.Marshaling- Copyright : © 2012-2019 John MacFarlane- © 2017-2019 Albert Krewinkel+ Copyright : © 2012-2020 John MacFarlane+ © 2017-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
src/Text/Pandoc/Lua/Marshaling/AST.hs view
@@ -1,12 +1,9 @@ {-# OPTIONS_GHC -fno-warn-orphans #-}-{-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE LambdaCase #-} {- | Module : Text.Pandoc.Lua.Marshaling.AST- Copyright : © 2012-2019 John MacFarlane- © 2017-2019 Albert Krewinkel+ Copyright : © 2012-2020 John MacFarlane+ © 2017-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -19,7 +16,6 @@ , LuaListAttributes (..) ) where -import Prelude import Control.Applicative ((<|>)) import Foreign.Lua (Lua, Peekable, Pushable, StackIndex) import Text.Pandoc.Definition
src/Text/Pandoc/Lua/Marshaling/AnyValue.hs view
@@ -1,7 +1,6 @@-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.Lua.Marshaling.AnyValue- Copyright : © 2017-2019 Albert Krewinkel+ Copyright : © 2017-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -15,7 +14,6 @@ -} module Text.Pandoc.Lua.Marshaling.AnyValue (AnyValue (..)) where -import Prelude import Foreign.Lua (Peekable (peek), StackIndex) -- | Dummy type to allow values of arbitrary Lua type. This just wraps
src/Text/Pandoc/Lua/Marshaling/CommonState.hs view
@@ -1,11 +1,10 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} {-# LANGUAGE LambdaCase #-}-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Lua.Marshaling.CommonState- Copyright : © 2012-2019 John MacFarlane- © 2017-2019 Albert Krewinkel+ Copyright : © 2012-2020 John MacFarlane+ © 2017-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de> Stability : alpha@@ -14,7 +13,6 @@ -} module Text.Pandoc.Lua.Marshaling.CommonState () where -import Prelude import Foreign.Lua (Lua, Peekable, Pushable) import Foreign.Lua.Types.Peekable (reportValueOnFailure) import Foreign.Lua.Userdata (ensureUserdataMetatable, pushAnyWithMetatable,
src/Text/Pandoc/Lua/Marshaling/Context.hs view
@@ -1,11 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE ScopedTypeVariables #-} {-# OPTIONS_GHC -fno-warn-orphans #-} {- | Module : Text.Pandoc.Lua.Marshaling.Context- Copyright : © 2012-2019 John MacFarlane- © 2017-2019 Albert Krewinkel+ Copyright : © 2012-2020 John MacFarlane+ © 2017-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -15,7 +12,6 @@ -} module Text.Pandoc.Lua.Marshaling.Context () where -import Prelude import qualified Foreign.Lua as Lua import Foreign.Lua (Pushable) import Text.DocTemplates (Context(..), Val(..), TemplateTarget)
src/Text/Pandoc/Lua/Marshaling/List.hs view
@@ -1,7 +1,6 @@-{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE UndecidableInstances #-} {- | Module : Text.Pandoc.Lua.Marshaling.List@@ -17,7 +16,6 @@ ( List (..) ) where -import Prelude import Data.Data (Data) import Foreign.Lua (Peekable, Pushable) import Text.Pandoc.Walk (Walkable (..))
src/Text/Pandoc/Lua/Marshaling/MediaBag.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.Lua.Marshaling.MediaBag- Copyright : © 2012-2019 John MacFarlane- © 2017-2019 Albert Krewinkel+ Copyright : © 2012-2020 John MacFarlane+ © 2017-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de> Stability : alpha@@ -11,7 +10,6 @@ -} module Text.Pandoc.Lua.Marshaling.MediaBag (pushIterator) where -import Prelude import Foreign.Ptr (Ptr) import Foreign.StablePtr (StablePtr, deRefStablePtr, newStablePtr) import Foreign.Lua (Lua, NumResults, Peekable, Pushable, StackIndex)
src/Text/Pandoc/Lua/Marshaling/ReaderOptions.hs view
@@ -1,13 +1,11 @@-{-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE LambdaCase #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-} {-# OPTIONS_GHC -fno-warn-orphans #-} {- | Module : Text.Pandoc.Lua.Marshaling.ReaderOptions- Copyright : © 2012-2019 John MacFarlane- © 2017-2019 Albert Krewinkel+ Copyright : © 2012-2020 John MacFarlane+ © 2017-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -17,7 +15,6 @@ -} module Text.Pandoc.Lua.Marshaling.ReaderOptions () where -import Prelude import Data.Data (showConstr, toConstr) import Foreign.Lua (Lua, Pushable) import Text.Pandoc.Extensions (Extensions)
src/Text/Pandoc/Lua/Marshaling/Version.hs view
@@ -1,11 +1,10 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} {-# LANGUAGE LambdaCase #-}-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {- | Module : Text.Pandoc.Lua.Marshaling.Version- Copyright : © 2019 Albert Krewinkel+ Copyright : © 2019-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -20,7 +19,6 @@ ) where -import Prelude import Data.Text (Text) import Data.Maybe (fromMaybe) import Data.Version (Version (..), makeVersion, parseVersion, showVersion)
src/Text/Pandoc/Lua/Module/MediaBag.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Lua.Module.MediaBag- Copyright : Copyright © 2017-2019 Albert Krewinkel+ Copyright : Copyright © 2017-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -14,11 +13,11 @@ ( pushModule ) where -import Prelude import Control.Monad (zipWithM_) import Foreign.Lua (Lua, NumResults, Optional, liftIO)-import Text.Pandoc.Class (CommonState (..), fetchItem, putCommonState,- runIOorExplode, setMediaBag)+import Text.Pandoc.Class.CommonState (CommonState (..))+import Text.Pandoc.Class.PandocIO (runIOorExplode)+import Text.Pandoc.Class.PandocMonad (fetchItem, putCommonState, setMediaBag) import Text.Pandoc.Lua.Marshaling () import Text.Pandoc.Lua.Marshaling.MediaBag (pushIterator) import Text.Pandoc.Lua.Util (addFunction)
src/Text/Pandoc/Lua/Module/Pandoc.hs view
@@ -1,9 +1,8 @@ {-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Lua.Module.Pandoc- Copyright : Copyright © 2017-2019 Albert Krewinkel+ Copyright : Copyright © 2017-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -15,14 +14,13 @@ ( pushModule ) where -import Prelude import Control.Monad (when) import Control.Monad.Except (throwError) import Data.Default (Default (..)) import Data.Maybe (fromMaybe) import Foreign.Lua (Lua, NumResults, Optional, Peekable, Pushable) import System.Exit (ExitCode (..))-import Text.Pandoc.Class (runIO)+import Text.Pandoc.Class.PandocIO (runIO) import Text.Pandoc.Definition (Block, Inline) import Text.Pandoc.Lua.Filter (walkInlines, walkBlocks, LuaFilter, SingletonsList (..)) import Text.Pandoc.Lua.Marshaling ()
src/Text/Pandoc/Lua/Module/System.hs view
@@ -1,6 +1,6 @@ {- | Module : Text.Pandoc.Lua.Module.System- Copyright : © 2019 Albert Krewinkel+ Copyright : © 2019-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -12,7 +12,6 @@ ( pushModule ) where -import Prelude import Foreign.Lua (Lua, NumResults) import Foreign.Lua.Module.System (arch, env, getwd, os, with_env, with_tmpdir, with_wd)
src/Text/Pandoc/Lua/Module/Types.hs view
@@ -1,6 +1,6 @@ {- | Module : Text.Pandoc.Lua.Module.Types- Copyright : © 2019 Albert Krewinkel+ Copyright : © 2019-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -12,7 +12,6 @@ ( pushModule ) where -import Prelude import Data.Version (Version) import Foreign.Lua (Lua, NumResults) import Text.Pandoc.Definition
src/Text/Pandoc/Lua/Module/Utils.hs view
@@ -1,7 +1,6 @@-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.Lua.Module.Utils- Copyright : Copyright © 2017-2019 Albert Krewinkel+ Copyright : Copyright © 2017-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -13,12 +12,12 @@ ( pushModule ) where -import Prelude import Control.Applicative ((<|>)) import Data.Default (def) import Data.Version (Version) import Foreign.Lua (Peekable, Lua, NumResults)-import Text.Pandoc.Class (runIO, setUserDataDir)+import Text.Pandoc.Class.PandocIO (runIO)+import Text.Pandoc.Class.PandocMonad (setUserDataDir) import Text.Pandoc.Definition ( Pandoc, Meta, MetaValue (..), Block, Inline , Citation, Attr, ListAttributes) import Text.Pandoc.Lua.Marshaling ()
src/Text/Pandoc/Lua/Packages.hs view
@@ -1,9 +1,8 @@ {-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE ScopedTypeVariables #-} {- | Module : Text.Pandoc.Lua.Packages- Copyright : Copyright © 2017-2019 Albert Krewinkel+ Copyright : Copyright © 2017-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -16,11 +15,11 @@ , installPandocPackageSearcher ) where -import Prelude import Control.Monad (forM_) import Data.ByteString (ByteString) import Foreign.Lua (Lua, NumResults, liftIO)-import Text.Pandoc.Class (readDataFile, runIO, setUserDataDir)+import Text.Pandoc.Class.PandocIO (runIO)+import Text.Pandoc.Class.PandocMonad (readDataFile, setUserDataDir) import qualified Foreign.Lua as Lua import Text.Pandoc.Lua.Module.Pandoc as Pandoc
src/Text/Pandoc/Lua/Util.hs view
@@ -1,11 +1,10 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE LambdaCase #-}-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Lua.Util- Copyright : © 2012–2019 John MacFarlane,- © 2017-2019 Albert Krewinkel+ Copyright : © 2012–2020 John MacFarlane,+ © 2017-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -27,11 +26,11 @@ , dofileWithTraceback ) where -import Prelude import Control.Monad (unless, when) import Foreign.Lua ( Lua, NumArgs, NumResults, Peekable, Pushable, StackIndex , Status, ToHaskellFunction )-import Text.Pandoc.Class (readDataFile, runIOorExplode, setUserDataDir)+import Text.Pandoc.Class.PandocIO (runIOorExplode)+import Text.Pandoc.Class.PandocMonad (readDataFile, setUserDataDir) import qualified Foreign.Lua as Lua import qualified Text.Pandoc.UTF8 as UTF8 import Data.Text (Text)
src/Text/Pandoc/Lua/Walk.hs view
@@ -1,12 +1,11 @@ {-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE MultiParamTypeClasses #-} {- | Module : Text.Pandoc.Lua.Walk-Copyright : © 2012–2019 John MacFarlane,- © 2017-2019 Albert Krewinkel+Copyright : © 2012–2020 John MacFarlane,+ © 2017-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de> Stability : alpha@@ -18,7 +17,6 @@ ) where -import Prelude import Control.Monad ((<=<)) import Text.Pandoc.Definition import Text.Pandoc.Walk
src/Text/Pandoc/MIME.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.MIME- Copyright : Copyright (C) 2011-2019 John MacFarlane+ Copyright : Copyright (C) 2011-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -13,7 +12,6 @@ -} module Text.Pandoc.MIME ( MimeType, getMimeType, getMimeTypeDef, extensionFromMimeType, mediaCategory ) where-import Prelude import Data.List (isPrefixOf, isSuffixOf) import qualified Data.Map as M import qualified Data.Text as T
src/Text/Pandoc/MediaBag.hs view
@@ -1,10 +1,9 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {- | Module : Text.Pandoc.MediaBag- Copyright : Copyright (C) 2014-2015, 2017–2019 John MacFarlane+ Copyright : Copyright (C) 2014-2015, 2017–2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -22,7 +21,6 @@ mediaDirectory, mediaItems ) where-import Prelude import qualified Data.ByteString.Lazy as BL import Data.Data (Data) import qualified Data.Map as M
src/Text/Pandoc/Options.hs view
@@ -1,12 +1,11 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Options- Copyright : Copyright (C) 2012-2019 John MacFarlane+ Copyright : Copyright (C) 2012-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -33,7 +32,6 @@ , defaultMathJaxURL , defaultKaTeXURL ) where-import Prelude import Control.Applicative ((<|>)) import Data.Char (toLower) import Data.Maybe (fromMaybe)
src/Text/Pandoc/PDF.hs view
@@ -1,10 +1,9 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {- | Module : Text.Pandoc.PDF- Copyright : Copyright (C) 2012-2019 John MacFarlane+ Copyright : Copyright (C) 2012-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -15,7 +14,6 @@ -} module Text.Pandoc.PDF ( makePDF ) where -import Prelude import qualified Codec.Picture as JP import qualified Control.Exception as E import Control.Monad (when)@@ -54,9 +52,9 @@ import Data.List (intercalate) #endif import Data.List (isPrefixOf, find)-import Text.Pandoc.Class (PandocIO, extractMedia, fillMediaBag, getCommonState,- getVerbosity, putCommonState, report,- runIOorExplode, setVerbosity)+import Text.Pandoc.Class.PandocIO (PandocIO, extractMedia, runIOorExplode)+import Text.Pandoc.Class.PandocMonad (fillMediaBag, getCommonState, getVerbosity,+ putCommonState, report, setVerbosity) import Text.Pandoc.Logging #ifdef _WINDOWS@@ -142,7 +140,7 @@ (return . literal . stringify) meta let toArgs (f, mbd) = maybe [] (\d -> ["--" <> f, T.unpack d]) mbd- let args = pdfargs ++ mathArgs ++ concatMap toArgs+ let args = mathArgs ++ concatMap toArgs [("page-size", getField "papersize" meta') ,("title", getField "title" meta') ,("margin-bottom", Just $ fromMaybe "1.2in"@@ -155,7 +153,7 @@ (getField "margin-left" meta')) ,("footer-html", getField "footer-html" meta') ,("header-html", getField "header-html" meta')- ]+ ] ++ pdfargs source <- writer opts doc verbosity <- getVerbosity liftIO $ html2pdf verbosity program args source
src/Text/Pandoc/Parsing.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE CPP #-} {-# LANGUAGE ExplicitForAll #-} {-# LANGUAGE FlexibleContexts #-}@@ -10,7 +9,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Parsing- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -186,7 +185,6 @@ ) where -import Prelude import Control.Monad.Identity import Control.Monad.Reader import Data.Char (chr, isAlphaNum, isAscii, isAsciiUpper,@@ -204,7 +202,7 @@ import Text.Pandoc.Asciify (toAsciiChar) import Text.Pandoc.Builder (Blocks, HasMeta (..), Inlines, trimInlines) import qualified Text.Pandoc.Builder as B-import Text.Pandoc.Class (PandocMonad, readFileFromDirs, report)+import Text.Pandoc.Class.PandocMonad (PandocMonad, readFileFromDirs, report) import Text.Pandoc.Definition import Text.Pandoc.Logging import Text.Pandoc.Options
src/Text/Pandoc/Process.hs view
@@ -1,7 +1,6 @@-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.Process- Copyright : Copyright (C) 2013-2019 John MacFarlane+ Copyright : Copyright (C) 2013-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -12,7 +11,6 @@ -} module Text.Pandoc.Process (pipeProcess) where-import Prelude import Control.Concurrent (MVar, forkIO, killThread, newEmptyMVar, putMVar, takeMVar) import Control.Exception (SomeException (..))
src/Text/Pandoc/Readers.hs view
@@ -1,10 +1,9 @@ {-# LANGUAGE MonoLocalBinds #-}-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -57,7 +56,6 @@ , getDefaultExtensions ) where -import Prelude import Control.Monad (unless) import Control.Monad.Except (throwError) import Data.Aeson
src/Text/Pandoc/Readers/CSV.hs view
@@ -1,10 +1,9 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ScopedTypeVariables #-} {- | Module : Text.Pandoc.Readers.RST- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -14,7 +13,6 @@ Conversion from CSV to a 'Pandoc' table. -} module Text.Pandoc.Readers.CSV ( readCSV ) where-import Prelude import Data.Text (Text) import qualified Data.Text as T import Text.Pandoc.CSV (parseCSV, defaultCSVOptions)
src/Text/Pandoc/Readers/CommonMark.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Readers.CommonMark- Copyright : Copyright (C) 2015-2019 John MacFarlane+ Copyright : Copyright (C) 2015-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -17,13 +16,12 @@ module Text.Pandoc.Readers.CommonMark (readCommonMark) where -import Prelude import CMarkGFM import Control.Monad.State import qualified Data.Set as Set import Data.Text (Text) import qualified Data.Text as T-import Text.Pandoc.Class (PandocMonad)+import Text.Pandoc.Class.PandocMonad (PandocMonad) import Text.Pandoc.Definition import Text.Pandoc.Emoji (emojiToInline) import Text.Pandoc.Options
src/Text/Pandoc/Readers/Creole.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.Creole@@ -14,14 +13,13 @@ module Text.Pandoc.Readers.Creole ( readCreole ) where -import Prelude import Control.Monad.Except (guard, liftM2, throwError) import qualified Data.Foldable as F import Data.Maybe (fromMaybe) import Data.Text (Text) import qualified Data.Text as T import qualified Text.Pandoc.Builder as B-import Text.Pandoc.Class (PandocMonad (..))+import Text.Pandoc.Class.PandocMonad (PandocMonad (..)) import Text.Pandoc.Definition import Text.Pandoc.Options import Text.Pandoc.Parsing hiding (enclosed)
src/Text/Pandoc/Readers/DocBook.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.DocBook- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -12,7 +11,6 @@ Conversion of DocBook XML to 'Pandoc' document. -} module Text.Pandoc.Readers.DocBook ( readDocBook ) where-import Prelude import Control.Monad.State.Strict import Data.Char (isSpace, toUpper) import Data.Default@@ -25,7 +23,7 @@ import qualified Data.Text as T import Text.HTML.TagSoup.Entity (lookupEntity) import Text.Pandoc.Builder-import Text.Pandoc.Class (PandocMonad, report)+import Text.Pandoc.Class.PandocMonad (PandocMonad, report) import Text.Pandoc.Options import Text.Pandoc.Logging (LogMessage(..)) import Text.Pandoc.Shared (crFilter, safeRead)
src/Text/Pandoc/Readers/Docx.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PatternGuards #-}@@ -7,7 +6,7 @@ {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Readers.Docx- Copyright : Copyright (C) 2014-2019 Jesse Rosenthal+ Copyright : Copyright (C) 2014-2020 Jesse Rosenthal License : GNU GPL, version 2 or above Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>@@ -60,7 +59,6 @@ ( readDocx ) where -import Prelude import Codec.Archive.Zip import Control.Monad.Reader import Control.Monad.State.Strict@@ -84,8 +82,8 @@ import Text.Pandoc.Walk import Text.TeXMath (writeTeX) import Control.Monad.Except (throwError)-import Text.Pandoc.Class (PandocMonad)-import qualified Text.Pandoc.Class as P+import Text.Pandoc.Class.PandocMonad (PandocMonad)+import qualified Text.Pandoc.Class.PandocMonad as P import Text.Pandoc.Error import Text.Pandoc.Logging
src/Text/Pandoc/Readers/Docx/Combine.hs view
@@ -1,11 +1,10 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE PatternGuards #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.Docx.Combine- Copyright : © 2014-2019 Jesse Rosenthal <jrosenthal@jhu.edu>,- 2014-2019 John MacFarlane <jgm@berkeley.edu>+ Copyright : © 2014-2020 Jesse Rosenthal <jrosenthal@jhu.edu>,+ 2014-2020 John MacFarlane <jgm@berkeley.edu> License : GNU GPL, version 2 or above Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>@@ -59,7 +58,6 @@ ) where -import Prelude import Data.List import Data.Sequence (ViewL (..), ViewR (..), viewl, viewr, (><), (|>)) import qualified Data.Sequence as Seq (null)
src/Text/Pandoc/Readers/Docx/Fields.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.Docx.Fields- Copyright : Copyright (C) 2014-2019 Jesse Rosenthal+ Copyright : Copyright (C) 2014-2020 Jesse Rosenthal License : GNU GPL, version 2 or above Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>@@ -16,7 +15,6 @@ , parseFieldInfo ) where -import Prelude import Data.Functor (($>), void) import qualified Data.Text as T import Text.Parsec
src/Text/Pandoc/Readers/Docx/Lists.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.Docx.Lists- Copyright : Copyright (C) 2014-2019 Jesse Rosenthal+ Copyright : Copyright (C) 2014-2020 Jesse Rosenthal License : GNU GPL, version 2 or above Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>@@ -18,7 +17,6 @@ , listParagraphStyles ) where -import Prelude import Data.List import Data.Maybe import Data.String (fromString)
src/Text/Pandoc/Readers/Docx/Parse.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE ViewPatterns #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.Docx.Parse- Copyright : Copyright (C) 2014-2019 Jesse Rosenthal+ Copyright : Copyright (C) 2014-2020 Jesse Rosenthal 2019 Nikolay Yakimov <root@livid.pp.ru> License : GNU GPL, version 2 or above @@ -52,7 +51,6 @@ , constructBogusParStyleData , leftBiasedMergeRunStyle ) where-import Prelude import Text.Pandoc.Readers.Docx.Parse.Styles import Codec.Archive.Zip import Control.Applicative ((<|>))
src/Text/Pandoc/Readers/Docx/Parse/Styles.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE TypeFamilies #-}@@ -6,7 +5,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.Docx.Parse.Styles- Copyright : Copyright (C) 2014-2019 Jesse Rosenthal+ Copyright : Copyright (C) 2014-2020 Jesse Rosenthal 2019 Nikolay Yakimov <root@livid.pp.ru> License : GNU GPL, version 2 or above @@ -43,7 +42,6 @@ , defaultRunStyle , checkOnOff ) where-import Prelude import Codec.Archive.Zip import Control.Applicative ((<|>)) import Control.Monad.Except
src/Text/Pandoc/Readers/Docx/Util.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.Readers.Docx.StyleMaps- Copyright : © 2014-2019 Jesse Rosenthal <jrosenthal@jhu.edu>,- 2014-2019 John MacFarlane <jgm@berkeley.edu>,+ Copyright : © 2014-2020 Jesse Rosenthal <jrosenthal@jhu.edu>,+ 2014-2020 John MacFarlane <jgm@berkeley.edu>, 2015 Nikolay Yakimov <root@livid.pp.ru> License : GNU GPL, version 2 or above @@ -24,7 +23,6 @@ , findAttrTextByName ) where -import Prelude import Data.Maybe (mapMaybe) import qualified Data.Text as T import Text.XML.Light
src/Text/Pandoc/Readers/DokuWiki.hs view
@@ -1,11 +1,10 @@ {-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Readers.DokuWiki- Copyright : Copyright (C) 2018-2019 Alexander Krotov+ Copyright : Copyright (C) 2018-2020 Alexander Krotov License : GNU GPL, version 2 or above Maintainer : Alexander Krotov <ilabdsf@gmail.com>@@ -16,7 +15,6 @@ -} module Text.Pandoc.Readers.DokuWiki (readDokuWiki) where -import Prelude import Control.Monad import Control.Monad.Except (throwError) import Data.Char (isAlphaNum, isDigit)@@ -26,7 +24,7 @@ import Data.Text (Text) import qualified Data.Text as T import qualified Text.Pandoc.Builder as B-import Text.Pandoc.Class (PandocMonad (..))+import Text.Pandoc.Class.PandocMonad (PandocMonad (..)) import Text.Pandoc.Definition import Text.Pandoc.Error (PandocError (PandocParsecError)) import Text.Pandoc.Options
src/Text/Pandoc/Readers/EPUB.hs view
@@ -1,10 +1,9 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE ViewPatterns #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.EPUB- Copyright : Copyright (C) 2014-2019 Matthew Pickering+ Copyright : Copyright (C) 2014-2020 Matthew Pickering License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -18,7 +17,6 @@ (readEPUB) where -import Prelude import Codec.Archive.Zip (Archive (..), Entry, findEntryByPath, fromEntry, toArchiveOrFail) import Control.DeepSeq (NFData, deepseq)@@ -35,7 +33,7 @@ import System.FilePath (dropFileName, dropFileName, normalise, splitFileName, takeFileName, (</>)) import qualified Text.Pandoc.Builder as B-import Text.Pandoc.Class (PandocMonad, insertMedia)+import Text.Pandoc.Class.PandocMonad (PandocMonad, insertMedia) import Text.Pandoc.Definition hiding (Attr) import Text.Pandoc.Error import Text.Pandoc.Extensions (Extension (Ext_raw_html), enableExtension)
src/Text/Pandoc/Readers/FB2.hs view
@@ -3,7 +3,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.FB2- Copyright : Copyright (C) 2018-2019 Alexander Krotov+ Copyright : Copyright (C) 2018-2020 Alexander Krotov License : GNU GPL, version 2 or above Maintainer : Alexander Krotov <ilabdsf@gmail.com>@@ -23,7 +23,6 @@ -} module Text.Pandoc.Readers.FB2 ( readFB2 ) where-import Prelude import Control.Monad.Except (throwError) import Control.Monad.State.Strict import Data.ByteString.Lazy.Char8 ( pack )@@ -37,7 +36,7 @@ import Data.Maybe import Text.HTML.TagSoup.Entity (lookupEntity) import Text.Pandoc.Builder-import Text.Pandoc.Class (PandocMonad, insertMedia, report)+import Text.Pandoc.Class.PandocMonad (PandocMonad, insertMedia, report) import Text.Pandoc.Error import Text.Pandoc.Logging import Text.Pandoc.Options
src/Text/Pandoc/Readers/HTML.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-}@@ -7,7 +6,7 @@ {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Readers.HTML- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -26,7 +25,6 @@ , isCommentTag ) where -import Prelude import Control.Applicative ((<|>)) import Control.Arrow (first) import Control.Monad (guard, mplus, msum, mzero, unless, void)@@ -47,7 +45,7 @@ import Text.HTML.TagSoup.Match import Text.Pandoc.Builder (Blocks, HasMeta (..), Inlines, trimInlines) import qualified Text.Pandoc.Builder as B-import Text.Pandoc.Class (PandocMonad (..))+import Text.Pandoc.Class.PandocMonad (PandocMonad (..)) import Text.Pandoc.CSS (foldOrElse, pickStyleAttrProps) import Text.Pandoc.Definition import Text.Pandoc.Readers.LaTeX (rawLaTeXInline)
src/Text/Pandoc/Readers/Haddock.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} {- |@@ -16,7 +15,6 @@ ( readHaddock ) where -import Prelude import Control.Monad.Except (throwError) import Data.List (intersperse) import Data.Maybe (fromMaybe)@@ -26,7 +24,7 @@ import Documentation.Haddock.Types as H import Text.Pandoc.Builder (Blocks, Inlines) import qualified Text.Pandoc.Builder as B-import Text.Pandoc.Class (PandocMonad)+import Text.Pandoc.Class.PandocMonad (PandocMonad) import Text.Pandoc.Definition import Text.Pandoc.Error import Text.Pandoc.Options
src/Text/Pandoc/Readers/Ipynb.hs view
@@ -1,11 +1,10 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ScopedTypeVariables #-} {- | Module : Text.Pandoc.Readers.Ipynb- Copyright : Copyright (C) 2019 John MacFarlane+ Copyright : Copyright (C) 2019-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -16,7 +15,6 @@ -} module Text.Pandoc.Readers.Ipynb ( readIpynb ) where-import Prelude import Data.Char (isDigit) import Data.Maybe (fromMaybe) import Data.Digest.Pure.SHA (sha1, showDigest)@@ -26,7 +24,7 @@ import Text.Pandoc.Logging import Text.Pandoc.Definition import Data.Ipynb as Ipynb-import Text.Pandoc.Class+import Text.Pandoc.Class.PandocMonad import Text.Pandoc.MIME (extensionFromMimeType) import Text.Pandoc.Shared (tshow) import Text.Pandoc.UTF8
src/Text/Pandoc/Readers/JATS.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.JATS- Copyright : Copyright (C) 2017-2019 Hamish Mackenzie+ Copyright : Copyright (C) 2017-2020 Hamish Mackenzie License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -14,7 +13,6 @@ -} module Text.Pandoc.Readers.JATS ( readJATS ) where-import Prelude import Control.Monad.State.Strict import Data.Char (isDigit, isSpace, toUpper) import Data.Default@@ -26,7 +24,7 @@ import qualified Data.Text as T import Text.HTML.TagSoup.Entity (lookupEntity) import Text.Pandoc.Builder-import Text.Pandoc.Class (PandocMonad)+import Text.Pandoc.Class.PandocMonad (PandocMonad) import Text.Pandoc.Options import Text.Pandoc.Shared (underlineSpan, crFilter, safeRead) import Text.TeXMath (readMathML, writeTeX)
src/Text/Pandoc/Readers/Jira.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.Org- Copyright : © 2019 Albert Krewinkel+ Copyright : © 2019-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -12,12 +11,11 @@ -} module Text.Pandoc.Readers.Jira ( readJira ) where -import Prelude import Control.Monad.Except (throwError) import Data.Text (Text, append, pack, singleton, unpack) import Text.HTML.TagSoup.Entity (lookupEntity) import Text.Jira.Parser (parse)-import Text.Pandoc.Class (PandocMonad (..))+import Text.Pandoc.Class.PandocMonad (PandocMonad (..)) import Text.Pandoc.Builder import Text.Pandoc.Error (PandocError (PandocParseError)) import Text.Pandoc.Options (ReaderOptions)@@ -121,6 +119,8 @@ jiraToPandocInlines = \case Jira.Anchor t -> spanWith (t, [], []) mempty Jira.AutoLink url -> link (Jira.fromURL url) "" (str (Jira.fromURL url))+ Jira.ColorInline c ils -> spanWith ("", [], [("color", colorName c)]) $+ fromInlines ils Jira.Emoji icon -> str . iconUnicode $ icon Jira.Entity entity -> str . fromEntity $ entity Jira.Image _ url -> image (Jira.fromURL url) "" mempty
src/Text/Pandoc/Readers/LaTeX.hs view
@@ -1,5 +1,4 @@ {-# LANGUAGE CPP #-}-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings #-}@@ -8,7 +7,7 @@ {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Readers.LaTeX- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -27,7 +26,6 @@ untokenize ) where -import Prelude import Control.Applicative (many, optional, (<|>)) import Control.Monad import Control.Monad.Except (throwError)@@ -42,9 +40,10 @@ import System.FilePath (addExtension, replaceExtension, takeExtension) import Text.Pandoc.BCP47 (Lang (..), renderLang) import Text.Pandoc.Builder-import Text.Pandoc.Class (PandocMonad, PandocPure, getResourcePath, lookupEnv,- readFileFromDirs, report, setResourcePath,- setTranslations, translateTerm, trace, fileExists)+import Text.Pandoc.Class.PandocPure (PandocPure)+import Text.Pandoc.Class.PandocMonad (PandocMonad (..), getResourcePath,+ readFileFromDirs, report, setResourcePath,+ setTranslations, translateTerm) import Text.Pandoc.Error (PandocError (PandocParseError, PandocParsecError)) import Text.Pandoc.Highlighting (fromListingsLanguage, languagesByExtension) import Text.Pandoc.ImageSize (numUnit, showFl)@@ -66,7 +65,7 @@ -- for debugging: -- import Text.Pandoc.Extensions (getDefaultExtensions)--- import Text.Pandoc.Class (runIOorExplode, PandocIO)+-- import Text.Pandoc.Class.PandocIO (runIOorExplode, PandocIO) -- import Debug.Trace (traceShowId) -- | Parse LaTeX from string and return 'Pandoc' document.
src/Text/Pandoc/Readers/LaTeX/Lang.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.LaTeX.Lang- Copyright : Copyright (C) 2018-2019 John MacFarlane+ Copyright : Copyright (C) 2018-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -17,7 +16,6 @@ , babelLangToBCP47 ) where-import Prelude import qualified Data.Map as M import qualified Data.Text as T import Text.Pandoc.BCP47 (Lang(..))
src/Text/Pandoc/Readers/LaTeX/Parsing.hs view
@@ -1,11 +1,10 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {- | Module : Text.Pandoc.Readers.LaTeX.Parsing- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -69,7 +68,6 @@ , withRaw ) where -import Prelude import Control.Applicative (many, (<|>)) import Control.Monad import Control.Monad.Except (throwError)@@ -82,7 +80,7 @@ import Data.Text (Text) import qualified Data.Text as T import Text.Pandoc.Builder-import Text.Pandoc.Class (PandocMonad, report)+import Text.Pandoc.Class.PandocMonad (PandocMonad, report) import Text.Pandoc.Error (PandocError (PandocMacroLoop)) import Text.Pandoc.Logging import Text.Pandoc.Options
src/Text/Pandoc/Readers/LaTeX/Types.hs view
@@ -1,7 +1,6 @@-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.Readers.LaTeX.Types- Copyright : Copyright (C) 2017-2019 John MacFarlane+ Copyright : Copyright (C) 2017-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -18,7 +17,6 @@ , SourcePos ) where-import Prelude import Data.Text (Text) import Text.Parsec.Pos (SourcePos)
src/Text/Pandoc/Readers/Man.hs view
@@ -3,7 +3,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.Man- Copyright : Copyright (C) 2018-2019 Yan Pashkovsky and John MacFarlane+ Copyright : Copyright (C) 2018-2020 Yan Pashkovsky and John MacFarlane License : GNU GPL, version 2 or above Maintainer : Yan Pashkovsky <yanp.bugz@gmail.com>@@ -14,17 +14,16 @@ -} module Text.Pandoc.Readers.Man (readMan) where -import Prelude import Data.Char (toLower) import Data.Default (Default) import Control.Monad (liftM, mzero, guard, void) import Control.Monad.Trans (lift) import Control.Monad.Except (throwError)-import Text.Pandoc.Class (PandocMonad(..), report) import Data.Maybe (catMaybes, isJust) import Data.List (intersperse, intercalate) import qualified Data.Text as T import Text.Pandoc.Builder as B+import Text.Pandoc.Class.PandocMonad (PandocMonad(..), report) import Text.Pandoc.Error (PandocError (PandocParsecError)) import Text.Pandoc.Logging (LogMessage(..)) import Text.Pandoc.Options
src/Text/Pandoc/Readers/Markdown.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE RelaxedPolyRec #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TupleSections #-}@@ -6,7 +5,7 @@ {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Readers.Markdown- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -17,7 +16,6 @@ -} module Text.Pandoc.Readers.Markdown ( readMarkdown, yamlToMeta ) where -import Prelude import Control.Monad import Control.Monad.Except (throwError) import Data.Char (isAlphaNum, isPunctuation, isSpace)@@ -33,7 +31,7 @@ import Text.HTML.TagSoup import Text.Pandoc.Builder (Blocks, Inlines) import qualified Text.Pandoc.Builder as B-import Text.Pandoc.Class (PandocMonad (..), report)+import Text.Pandoc.Class.PandocMonad (PandocMonad (..), report) import Text.Pandoc.Definition import Text.Pandoc.Emoji (emojiToInline) import Text.Pandoc.Error@@ -1183,7 +1181,7 @@ let nonempties = filter (not . T.null) $ map trimr strLst (leftSpace, rightSpace) = case sortOn T.length nonempties of- (x:_) -> (T.head x `elem` [' ', 't'], T.length x < len)+ (x:_) -> (T.head x `elem` [' ', '\t'], T.length x < len) [] -> (False, False) in case (leftSpace, rightSpace) of (True, False) -> AlignRight
src/Text/Pandoc/Readers/MediaWiki.hs view
@@ -1,10 +1,9 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RelaxedPolyRec #-} -- RelaxedPolyRec needed for inlinesBetween on GHC < 7 {- | Module : Text.Pandoc.Readers.MediaWiki- Copyright : Copyright (C) 2012-2019 John MacFarlane+ Copyright : Copyright (C) 2012-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -20,7 +19,6 @@ -} module Text.Pandoc.Readers.MediaWiki ( readMediaWiki ) where -import Prelude import Control.Monad import Control.Monad.Except (throwError) import Data.Char (isDigit, isSpace)@@ -34,7 +32,7 @@ import Text.HTML.TagSoup import Text.Pandoc.Builder (Blocks, Inlines, trimInlines) import qualified Text.Pandoc.Builder as B-import Text.Pandoc.Class (PandocMonad (..))+import Text.Pandoc.Class.PandocMonad (PandocMonad (..)) import Text.Pandoc.Definition import Text.Pandoc.Logging import Text.Pandoc.Options
src/Text/Pandoc/Readers/Metadata.hs view
@@ -1,10 +1,9 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE RelaxedPolyRec #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.Metadata- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -15,7 +14,6 @@ -} module Text.Pandoc.Readers.Metadata ( yamlBsToMeta ) where -import Prelude import Control.Monad import Control.Monad.Except (throwError) import qualified Data.ByteString.Lazy as BL@@ -26,7 +24,7 @@ import qualified Data.YAML.Event as YE import qualified Text.Pandoc.Builder as B import Text.Pandoc.Builder (Blocks)-import Text.Pandoc.Class (PandocMonad (..))+import Text.Pandoc.Class.PandocMonad (PandocMonad (..)) import Text.Pandoc.Definition import Text.Pandoc.Error import Text.Pandoc.Logging
src/Text/Pandoc/Readers/Muse.hs view
@@ -1,10 +1,9 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.Muse- Copyright : Copyright (C) 2017-2019 Alexander Krotov+ Copyright : Copyright (C) 2017-2020 Alexander Krotov License : GNU GPL, version 2 or above Maintainer : Alexander Krotov <ilabdsf@gmail.com>@@ -19,7 +18,6 @@ -} module Text.Pandoc.Readers.Muse (readMuse) where -import Prelude import Control.Monad import Control.Monad.Reader import Control.Monad.Except (throwError)@@ -33,7 +31,7 @@ import qualified Data.Text as T import Text.Pandoc.Builder (Blocks, Inlines) import qualified Text.Pandoc.Builder as B-import Text.Pandoc.Class (PandocMonad (..))+import Text.Pandoc.Class.PandocMonad (PandocMonad (..)) import Text.Pandoc.Definition import Text.Pandoc.Error (PandocError (PandocParsecError)) import Text.Pandoc.Logging
src/Text/Pandoc/Readers/Native.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.Native- Copyright : Copyright (C) 2011-2019 John MacFarlane+ Copyright : Copyright (C) 2011-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -14,14 +13,13 @@ -} module Text.Pandoc.Readers.Native ( readNative ) where -import Prelude import Text.Pandoc.Definition import Text.Pandoc.Options (ReaderOptions) import Text.Pandoc.Shared (safeRead) import Control.Monad.Except (throwError) import Data.Text (Text)-import Text.Pandoc.Class+import Text.Pandoc.Class.PandocMonad (PandocMonad) import Text.Pandoc.Error -- | Read native formatted text and return a Pandoc document.
src/Text/Pandoc/Readers/OPML.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.OPML- Copyright : Copyright (C) 2013-2019 John MacFarlane+ Copyright : Copyright (C) 2013-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -13,7 +12,6 @@ -} module Text.Pandoc.Readers.OPML ( readOPML ) where-import Prelude import Control.Monad.State.Strict import Data.Char (toUpper) import Data.Default@@ -23,7 +21,7 @@ import qualified Data.Text as T import Text.HTML.TagSoup.Entity (lookupEntity) import Text.Pandoc.Builder-import Text.Pandoc.Class (PandocMonad)+import Text.Pandoc.Class.PandocMonad (PandocMonad) import Text.Pandoc.Options import Text.Pandoc.Readers.HTML (readHtml) import Text.Pandoc.Readers.Markdown (readMarkdown)
src/Text/Pandoc/Readers/Odt.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE PatternGuards #-} {-# LANGUAGE OverloadedStrings #-} {- |@@ -15,7 +14,6 @@ module Text.Pandoc.Readers.Odt ( readOdt ) where -import Prelude import Codec.Archive.Zip import qualified Text.XML.Light as XML @@ -25,8 +23,8 @@ import Control.Monad.Except (throwError) -import Text.Pandoc.Class (PandocMonad)-import qualified Text.Pandoc.Class as P+import Text.Pandoc.Class.PandocMonad (PandocMonad)+import qualified Text.Pandoc.Class.PandocMonad as P import Text.Pandoc.Definition import Text.Pandoc.Error import Text.Pandoc.MediaBag
src/Text/Pandoc/Readers/Odt/Arrows/State.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE TupleSections #-} {- |@@ -20,7 +19,6 @@ module Text.Pandoc.Readers.Odt.Arrows.State where -import Prelude import Control.Arrow import qualified Control.Category as Cat import Control.Monad
src/Text/Pandoc/Readers/Odt/Arrows/Utils.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.Readers.Odt.Arrows.Utils Copyright : Copyright (C) 2015 Martin Linnemann@@ -22,7 +21,6 @@ -- We export everything module Text.Pandoc.Readers.Odt.Arrows.Utils where -import Prelude import Control.Arrow import Control.Monad (join)
src/Text/Pandoc/Readers/Odt/ContentReader.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE Arrows #-} {-# LANGUAGE DeriveFoldable #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}@@ -24,7 +23,6 @@ , read_body ) where -import Prelude import Control.Applicative hiding (liftA, liftA2, liftA3) import Control.Arrow
src/Text/Pandoc/Readers/Odt/Generic/Fallible.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.Readers.Odt.Generic.Fallible Copyright : Copyright (C) 2015 Martin Linnemann@@ -19,7 +18,6 @@ -- We export everything module Text.Pandoc.Readers.Odt.Generic.Fallible where-import Prelude -- | Default for now. Will probably become a class at some point. type Failure = ()
src/Text/Pandoc/Readers/Odt/Generic/Namespaces.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.Readers.Odt.Generic.Namespaces Copyright : Copyright (C) 2015 Martin Linnemann@@ -14,7 +13,6 @@ module Text.Pandoc.Readers.Odt.Generic.Namespaces where -import Prelude import qualified Data.Map as M --
src/Text/Pandoc/Readers/Odt/Generic/SetMap.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.Readers.Odt.Generic.SetMap Copyright : Copyright (C) 2015 Martin Linnemann@@ -13,7 +12,6 @@ module Text.Pandoc.Readers.Odt.Generic.SetMap where -import Prelude import qualified Data.Map as M import qualified Data.Set as S
src/Text/Pandoc/Readers/Odt/Generic/Utils.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE ViewPatterns #-} {- |@@ -30,7 +29,6 @@ , composition ) where -import Prelude import Control.Category (Category, (<<<), (>>>)) import qualified Control.Category as Cat (id) import Control.Monad (msum)
src/Text/Pandoc/Readers/Odt/Generic/XMLConverter.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE PatternGuards #-}@@ -53,7 +52,6 @@ , matchContent ) where -import Prelude import Control.Applicative hiding ( liftA, liftA2 ) import Control.Monad ( MonadPlus ) import Control.Arrow
src/Text/Pandoc/Readers/Odt/Namespaces.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.Reader.Odt.Namespaces Copyright : Copyright (C) 2015 Martin Linnemann@@ -14,7 +13,6 @@ module Text.Pandoc.Readers.Odt.Namespaces ( Namespace (..) ) where -import Prelude import Data.List (isPrefixOf) import qualified Data.Map as M (empty, insert) import Data.Maybe (fromMaybe, listToMaybe)
src/Text/Pandoc/Readers/Odt/StyleReader.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE CPP #-} {-# LANGUAGE Arrows #-} {-# LANGUAGE RecordWildCards #-}@@ -39,7 +38,6 @@ , readStylesAt ) where -import Prelude import Control.Applicative hiding (liftA, liftA2, liftA3) import Control.Arrow
src/Text/Pandoc/Readers/Org.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.Org- Copyright : Copyright (C) 2014-2019 Albert Krewinkel+ Copyright : Copyright (C) 2014-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -11,12 +10,11 @@ -} module Text.Pandoc.Readers.Org ( readOrg ) where -import Prelude import Text.Pandoc.Readers.Org.Blocks (blockList, meta) import Text.Pandoc.Readers.Org.ParserState (optionsToParserState) import Text.Pandoc.Readers.Org.Parsing (OrgParser, readWithM) -import Text.Pandoc.Class (PandocMonad)+import Text.Pandoc.Class.PandocMonad (PandocMonad) import Text.Pandoc.Definition import Text.Pandoc.Options import Text.Pandoc.Parsing (reportLogMessages)
src/Text/Pandoc/Readers/Org/BlockStarts.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.Org.BlockStarts- Copyright : Copyright (C) 2014-2019 Albert Krewinkel+ Copyright : Copyright (C) 2014-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -24,7 +23,6 @@ , endOfBlock ) where -import Prelude import Control.Monad (void) import Data.Text (Text) import qualified Data.Text as T
src/Text/Pandoc/Readers/Org/Blocks.hs view
@@ -1,10 +1,9 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.Org.Blocks- Copyright : Copyright (C) 2014-2019 Albert Krewinkel+ Copyright : Copyright (C) 2014-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -16,7 +15,6 @@ , meta ) where -import Prelude import Text.Pandoc.Readers.Org.BlockStarts import Text.Pandoc.Readers.Org.DocumentTree (documentTree, unprunedHeadlineToBlocks)@@ -28,7 +26,7 @@ originalLang, translateLang, exportsCode) import Text.Pandoc.Builder (Blocks, Inlines)-import Text.Pandoc.Class (PandocMonad)+import Text.Pandoc.Class.PandocMonad (PandocMonad) import Text.Pandoc.Definition import Text.Pandoc.Options import Text.Pandoc.Shared (compactify, compactifyDL, safeRead)
src/Text/Pandoc/Readers/Org/DocumentTree.hs view
@@ -1,10 +1,9 @@ {-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TupleSections #-} {- | Module : Text.Pandoc.Readers.Org.DocumentTree- Copyright : Copyright (C) 2014-2019 Albert Krewinkel+ Copyright : Copyright (C) 2014-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -16,14 +15,13 @@ , unprunedHeadlineToBlocks ) where -import Prelude import Control.Arrow ((***), first) import Control.Monad (guard) import Data.List (intersperse) import Data.Maybe (mapMaybe) import Data.Text (Text) import Text.Pandoc.Builder (Blocks, Inlines)-import Text.Pandoc.Class (PandocMonad)+import Text.Pandoc.Class.PandocMonad (PandocMonad) import Text.Pandoc.Definition import Text.Pandoc.Readers.Org.BlockStarts import Text.Pandoc.Readers.Org.ParserState
src/Text/Pandoc/Readers/Org/ExportSettings.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.Org.ExportSettings- Copyright : © 2016–2019 Albert Krewinkel+ Copyright : © 2016–2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -13,8 +12,7 @@ ( exportSettings ) where -import Prelude-import Text.Pandoc.Class (PandocMonad, report)+import Text.Pandoc.Class.PandocMonad (PandocMonad, report) import Text.Pandoc.Logging (LogMessage (UnknownOrgExportOption)) import Text.Pandoc.Readers.Org.ParserState import Text.Pandoc.Readers.Org.Parsing
src/Text/Pandoc/Readers/Org/Inlines.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.Org.Inlines- Copyright : Copyright (C) 2014-2019 Albert Krewinkel+ Copyright : Copyright (C) 2014-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -16,7 +15,6 @@ , linkTarget ) where -import Prelude import Text.Pandoc.Readers.Org.BlockStarts (endOfBlock, noteMarker) import Text.Pandoc.Readers.Org.ParserState import Text.Pandoc.Readers.Org.Parsing@@ -25,7 +23,7 @@ import Text.Pandoc.Builder (Inlines) import qualified Text.Pandoc.Builder as B-import Text.Pandoc.Class (PandocMonad)+import Text.Pandoc.Class.PandocMonad (PandocMonad) import Text.Pandoc.Definition import Text.Pandoc.Options import Text.Pandoc.Readers.LaTeX (inlineCommand, rawLaTeXInline)
src/Text/Pandoc/Readers/Org/Meta.hs view
@@ -1,10 +1,9 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.Org.Meta- Copyright : Copyright (C) 2014-2019 Albert Krewinkel+ Copyright : Copyright (C) 2014-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -17,7 +16,6 @@ , metaLine ) where -import Prelude import Text.Pandoc.Readers.Org.BlockStarts import Text.Pandoc.Readers.Org.ExportSettings (exportSettings) import Text.Pandoc.Readers.Org.Inlines@@ -26,7 +24,7 @@ import Text.Pandoc.Builder (Blocks, Inlines) import qualified Text.Pandoc.Builder as B-import Text.Pandoc.Class (PandocMonad)+import Text.Pandoc.Class.PandocMonad (PandocMonad) import Text.Pandoc.Definition import Text.Pandoc.Shared (safeRead)
src/Text/Pandoc/Readers/Org/ParserState.hs view
@@ -1,10 +1,9 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.Org.ParserState- Copyright : Copyright (C) 2014-2019 Albert Krewinkel+ Copyright : Copyright (C) 2014-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -39,7 +38,6 @@ , optionsToParserState ) where -import Prelude import Control.Monad.Reader (ReaderT, asks, local) import Data.Default (Default (..))
src/Text/Pandoc/Readers/Org/Parsing.hs view
@@ -1,7 +1,6 @@-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.Readers.Org.Parsing- Copyright : Copyright (C) 2014-2019 Albert Krewinkel+ Copyright : Copyright (C) 2014-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -104,7 +103,6 @@ , getPosition ) where -import Prelude import Data.Text (Text) import Text.Pandoc.Readers.Org.ParserState
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.Org.Shared- Copyright : Copyright (C) 2014-2019 Albert Krewinkel+ Copyright : Copyright (C) 2014-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -17,7 +16,6 @@ , exportsCode ) where -import Prelude import Data.Char (isAlphaNum) import Data.Text (Text) import qualified Data.Text as T
src/Text/Pandoc/Readers/RST.hs view
@@ -1,11 +1,10 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Readers.RST- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -15,7 +14,6 @@ Conversion from reStructuredText to 'Pandoc' document. -} module Text.Pandoc.Readers.RST ( readRST ) where-import Prelude import Control.Arrow (second) import Control.Monad (forM_, guard, liftM, mplus, mzero, when) import Control.Monad.Except (throwError)@@ -29,7 +27,7 @@ import qualified Data.Text as T import Text.Pandoc.Builder (Blocks, Inlines, fromList, setMeta, trimInlines) import qualified Text.Pandoc.Builder as B-import Text.Pandoc.Class (PandocMonad, fetchItem, readFileFromDirs)+import Text.Pandoc.Class.PandocMonad (PandocMonad, fetchItem, readFileFromDirs) import Text.Pandoc.CSV (CSVOptions (..), defaultCSVOptions, parseCSV) import Text.Pandoc.Definition import Text.Pandoc.Error
src/Text/Pandoc/Readers/Roff.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Readers.Roff- Copyright : Copyright (C) 2018-2019 Yan Pashkovsky and John MacFarlane+ Copyright : Copyright (C) 2018-2020 Yan Pashkovsky and John MacFarlane License : GNU GPL, version 2 or above Maintainer : Yan Pashkovsky <yanp.bugz@gmail.com>@@ -28,11 +28,10 @@ ) where -import Prelude import Safe (lastDef) import Control.Monad (void, mzero, mplus, guard) import Control.Monad.Except (throwError)-import Text.Pandoc.Class+import Text.Pandoc.Class.PandocMonad (getResourcePath, readFileFromDirs, PandocMonad(..), report) import Data.Char (isLower, toLower, toUpper, chr, isAscii, isAlphaNum) import Data.Default (Default)@@ -202,7 +201,7 @@ '*' -> escString ',' -> return mempty -- to fix spacing after roman '-' -> return [RoffStr "-"]- '.' -> return [RoffStr "`"]+ '.' -> return [RoffStr "."] '/' -> return mempty -- to fix spacing before roman '0' -> return [RoffStr "\x2007"] -- digit-width space ':' -> return mempty -- zero-width break@@ -226,7 +225,7 @@ 'X' -> escIgnore 'X' [quoteArg] 'Y' -> escIgnore 'Y' [escapeArg, countChar 1 (satisfy (/='\n'))] 'Z' -> escIgnore 'Z' [quoteArg]- '\'' -> return [RoffStr "`"]+ '\'' -> return [RoffStr "'"] '\n' -> return mempty -- line continuation '^' -> return [RoffStr "\x200A"] -- 1/12 em space '_' -> return [RoffStr "_"]
src/Text/Pandoc/Readers/TWiki.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RelaxedPolyRec #-}@@ -17,7 +16,6 @@ module Text.Pandoc.Readers.TWiki ( readTWiki ) where -import Prelude import Control.Monad import Control.Monad.Except (throwError) import Data.Char (isAlphaNum)@@ -27,7 +25,7 @@ import qualified Data.Text as T import Text.HTML.TagSoup import qualified Text.Pandoc.Builder as B-import Text.Pandoc.Class (PandocMonad (..))+import Text.Pandoc.Class.PandocMonad (PandocMonad (..)) import Text.Pandoc.Definition import Text.Pandoc.Options import Text.Pandoc.Parsing hiding (enclosed, nested)
src/Text/Pandoc/Readers/Textile.hs view
@@ -1,10 +1,9 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Readers.Textile Copyright : Copyright (C) 2010-2012 Paul Rivier- 2010-2019 John MacFarlane+ 2010-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : Paul Rivier <paul*rivier#demotera*com>@@ -36,7 +35,6 @@ module Text.Pandoc.Readers.Textile ( readTextile) where-import Prelude import Control.Monad (guard, liftM) import Control.Monad.Except (throwError) import Data.Char (digitToInt, isUpper)@@ -47,7 +45,7 @@ import Text.HTML.TagSoup.Match import Text.Pandoc.Builder (Blocks, Inlines, trimInlines) import qualified Text.Pandoc.Builder as B-import Text.Pandoc.Class (PandocMonad (..))+import Text.Pandoc.Class.PandocMonad (PandocMonad (..)) import Text.Pandoc.CSS import Text.Pandoc.Definition import Text.Pandoc.Options
src/Text/Pandoc/Readers/TikiWiki.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RelaxedPolyRec #-}@@ -18,7 +17,6 @@ module Text.Pandoc.Readers.TikiWiki ( readTikiWiki ) where -import Prelude import Control.Monad import Control.Monad.Except (throwError) import qualified Data.Foldable as F@@ -27,7 +25,8 @@ import Data.Text (Text) import qualified Data.Text as T import qualified Text.Pandoc.Builder as B-import Text.Pandoc.Class (CommonState (..), PandocMonad (..))+import Text.Pandoc.Class.CommonState (CommonState (..))+import Text.Pandoc.Class.PandocMonad (PandocMonad (..)) import Text.Pandoc.Definition import Text.Pandoc.Logging (Verbosity (..)) import Text.Pandoc.Options
src/Text/Pandoc/Readers/Txt2Tags.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Readers.Txt2Tags@@ -15,7 +14,6 @@ ) where -import Prelude import Control.Monad (guard, void, when) import Control.Monad.Except (catchError, throwError) import Control.Monad.Reader (Reader, asks, runReader)@@ -27,8 +25,8 @@ import Data.Time.Format (formatTime) import Text.Pandoc.Builder (Blocks, Inlines, trimInlines) import qualified Text.Pandoc.Builder as B-import Text.Pandoc.Class (PandocMonad)-import qualified Text.Pandoc.Class as P+import Text.Pandoc.Class.PandocMonad (PandocMonad)+import qualified Text.Pandoc.Class.PandocMonad as P import Data.Time (defaultTimeLocale) import Text.Pandoc.Definition import Text.Pandoc.Options
src/Text/Pandoc/Readers/Vimwiki.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE CPP #-} {- | Module : Text.Pandoc.Readers.Vimwiki- Copyright : Copyright (C) 2017-2019 Yuchen Pei+ Copyright : Copyright (C) 2017-2020 Yuchen Pei License : GNU GPL, version 2 or above Maintainer : Yuchen Pei <me@ypei.me>@@ -48,7 +47,6 @@ module Text.Pandoc.Readers.Vimwiki ( readVimwiki ) where-import Prelude import Control.Monad (guard) import Control.Monad.Except (throwError) import Data.Default@@ -66,7 +64,7 @@ softbreak, space, spanWith, str, strikeout, strong, subscript, superscript)-import Text.Pandoc.Class (PandocMonad (..))+import Text.Pandoc.Class.PandocMonad (PandocMonad (..)) import Text.Pandoc.Definition (Attr, Block (BulletList, OrderedList), Inline (Space), ListNumberDelim (..), ListNumberStyle (..), Pandoc (..),
src/Text/Pandoc/RoffChar.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.RoffChar- Copyright : Copyright (C) 2007-2019 John MacFarlane+ Copyright : Copyright (C) 2007-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -17,7 +16,6 @@ , characterCodes , combiningAccents ) where-import Prelude import qualified Data.Text as T -- | These are the escapes specifically mentioned in groff_man(7),
src/Text/Pandoc/SelfContained.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TupleSections #-} {- | Module : Text.Pandoc.SelfContained- Copyright : Copyright (C) 2011-2019 John MacFarlane+ Copyright : Copyright (C) 2011-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -15,7 +14,6 @@ the HTML using data URIs. -} module Text.Pandoc.SelfContained ( makeDataURI, makeSelfContained ) where-import Prelude import Codec.Compression.GZip as Gzip import Control.Applicative ((<|>)) import Control.Monad.Except (throwError)@@ -29,8 +27,8 @@ import Network.URI (escapeURIString) import System.FilePath (takeDirectory, takeExtension, (</>)) import Text.HTML.TagSoup-import Text.Pandoc.Class (PandocMonad (..), fetchItem, getInputFiles, report,- setInputFiles)+import Text.Pandoc.Class.PandocMonad (PandocMonad (..), fetchItem,+ getInputFiles, report, setInputFiles) import Text.Pandoc.Error import Text.Pandoc.Logging import Text.Pandoc.MIME (MimeType)
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE MultiParamTypeClasses #-}@@ -9,7 +8,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Shared- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -104,7 +103,6 @@ pandocVersion ) where -import Prelude import Codec.Archive.Zip import qualified Control.Exception as E import Control.Monad (MonadPlus (..), msum, unless)
src/Text/Pandoc/Slides.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Slides- Copyright : Copyright (C) 2012-2019 John MacFarlane+ Copyright : Copyright (C) 2012-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -13,7 +12,6 @@ show formats (dzslides, revealjs, s5, slidy, slideous, beamer). -} module Text.Pandoc.Slides ( getSlideLevel, prepSlides ) where-import Prelude import Text.Pandoc.Definition -- | Find level of header that starts slides (defined as the least header
src/Text/Pandoc/Templates.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Templates- Copyright : Copyright (C) 2009-2019 John MacFarlane+ Copyright : Copyright (C) 2009-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -24,11 +24,11 @@ , compileDefaultTemplate ) where -import Prelude import System.FilePath ((<.>), (</>), takeFileName) import Text.DocTemplates (Template, TemplateMonad(..), compileTemplate, renderTemplate)-import Text.Pandoc.Class (PandocMonad, readDataFile, fetchItem,- CommonState(..), getCommonState, modifyCommonState)+import Text.Pandoc.Class.CommonState (CommonState(..))+import Text.Pandoc.Class.PandocMonad (PandocMonad, readDataFile, fetchItem,+ getCommonState, modifyCommonState) import qualified Text.Pandoc.UTF8 as UTF8 import Control.Monad.Except (catchError, throwError) import Data.Text (Text)
src/Text/Pandoc/Translations.hs view
@@ -1,11 +1,10 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Translations- Copyright : Copyright (C) 2017-2019 John MacFarlane+ Copyright : Copyright (C) 2017-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -30,7 +29,6 @@ , readTranslations ) where-import Prelude import Data.Aeson.Types (Value(..), FromJSON(..)) import qualified Data.Aeson.Types as Aeson import qualified Data.HashMap.Strict as HM
src/Text/Pandoc/UTF8.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.UTF8- Copyright : Copyright (C) 2010-2019 John MacFarlane+ Copyright : Copyright (C) 2010-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>
src/Text/Pandoc/UUID.hs view
@@ -1,7 +1,6 @@-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.UUID- Copyright : Copyright (C) 2010-2019 John MacFarlane+ Copyright : Copyright (C) 2010-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -14,7 +13,6 @@ module Text.Pandoc.UUID ( UUID(..), getRandomUUID, getUUID ) where -import Prelude import Data.Bits (clearBit, setBit) import Data.Word import System.Random (RandomGen, getStdGen, randoms)
src/Text/Pandoc/Writers.hs view
@@ -1,11 +1,10 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -73,7 +72,6 @@ , getWriter ) where -import Prelude import Control.Monad.Except (throwError) import Control.Monad (unless) import Data.Aeson
src/Text/Pandoc/Writers/AsciiDoc.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Writers.AsciiDoc- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -20,7 +19,6 @@ AsciiDoc: <http://www.methods.co.nz/asciidoc/> -} module Text.Pandoc.Writers.AsciiDoc (writeAsciiDoc, writeAsciiDoctor) where-import Prelude import Control.Monad.State.Strict import Data.Char (isPunctuation, isSpace) import Data.List (intercalate, intersperse)@@ -28,7 +26,7 @@ import qualified Data.Set as Set import qualified Data.Text as T import Data.Text (Text)-import Text.Pandoc.Class (PandocMonad, report)+import Text.Pandoc.Class.PandocMonad (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.ImageSize import Text.Pandoc.Logging@@ -492,7 +490,6 @@ | otherwise = do report $ InlineNotRendered il return empty- | otherwise = return empty inlineToAsciiDoc _ LineBreak = return $ " +" <> cr inlineToAsciiDoc _ Space = return space inlineToAsciiDoc opts SoftBreak =
src/Text/Pandoc/Writers/CommonMark.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Writers.CommonMark- Copyright : Copyright (C) 2015-2019 John MacFarlane+ Copyright : Copyright (C) 2015-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -16,7 +15,6 @@ -} module Text.Pandoc.Writers.CommonMark (writeCommonMark) where -import Prelude import CMarkGFM import Control.Monad.State.Strict (State, get, modify, runState) import Data.Char (isAscii)@@ -25,7 +23,7 @@ import Data.Text (Text) import qualified Data.Text as T import Network.HTTP (urlEncode)-import Text.Pandoc.Class (PandocMonad)+import Text.Pandoc.Class.PandocMonad (PandocMonad) import Text.Pandoc.Definition import Text.Pandoc.Options import Text.Pandoc.Shared (capitalize, isTightList,
src/Text/Pandoc/Writers/ConTeXt.hs view
@@ -1,10 +1,9 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Writers.ConTeXt- Copyright : Copyright (C) 2007-2019 John MacFarlane+ Copyright : Copyright (C) 2007-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -14,7 +13,6 @@ Conversion of 'Pandoc' format into ConTeXt. -} module Text.Pandoc.Writers.ConTeXt ( writeConTeXt ) where-import Prelude import Control.Monad.State.Strict import Data.Char (ord, isDigit) import Data.List (intersperse)@@ -23,7 +21,7 @@ import qualified Data.Text as T import Network.URI (unEscapeString) import Text.Pandoc.BCP47-import Text.Pandoc.Class (PandocMonad, report, toLang)+import Text.Pandoc.Class.PandocMonad (PandocMonad, report, toLang) import Text.Pandoc.Definition import Text.Pandoc.ImageSize import Text.Pandoc.Logging
src/Text/Pandoc/Writers/Custom.hs view
@@ -1,9 +1,8 @@ {-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Writers.Custom- Copyright : Copyright (C) 2012-2019 John MacFarlane+ Copyright : Copyright (C) 2012-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -14,7 +13,6 @@ a lua writer. -} module Text.Pandoc.Writers.Custom ( writeCustom ) where-import Prelude import Control.Arrow ((***)) import Control.Exception import Control.Monad (when)@@ -25,7 +23,7 @@ import Data.Typeable import Foreign.Lua (Lua, Pushable) import Text.DocLayout (render, literal)-import Text.Pandoc.Class (PandocIO)+import Text.Pandoc.Class.PandocIO (PandocIO) import Text.Pandoc.Definition import Text.Pandoc.Lua (Global (..), LuaException (LuaException), runLua, setGlobals)
src/Text/Pandoc/Writers/Docbook.hs view
@@ -1,10 +1,9 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PatternGuards #-} {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Writers.Docbook- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -14,14 +13,13 @@ Conversion of 'Pandoc' documents to Docbook XML. -} module Text.Pandoc.Writers.Docbook ( writeDocbook4, writeDocbook5 ) where-import Prelude import Control.Monad.Reader import Data.Generics (everywhere, mkT) import Data.Monoid (Any (..)) import Data.Text (Text) import qualified Data.Text as T import qualified Text.Pandoc.Builder as B-import Text.Pandoc.Class (PandocMonad, report)+import Text.Pandoc.Class.PandocMonad (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.Highlighting (languages, languagesByExtension) import Text.Pandoc.ImageSize
src/Text/Pandoc/Writers/Docx.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE PatternGuards #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-}@@ -7,7 +6,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Writers.Docx- Copyright : Copyright (C) 2012-2019 John MacFarlane+ Copyright : Copyright (C) 2012-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -17,7 +16,6 @@ Conversion of 'Pandoc' documents to docx. -} module Text.Pandoc.Writers.Docx ( writeDocx ) where-import Prelude import Codec.Archive.Zip import Control.Applicative ((<|>)) import Control.Monad.Except (catchError, throwError)@@ -38,8 +36,8 @@ import Skylighting import System.Random (randomR, StdGen, mkStdGen) import Text.Pandoc.BCP47 (getLang, renderLang)-import Text.Pandoc.Class (PandocMonad, report, toLang)-import qualified Text.Pandoc.Class as P+import Text.Pandoc.Class.PandocMonad (PandocMonad, report, toLang)+import qualified Text.Pandoc.Class.PandocMonad as P import Data.Time import Text.Pandoc.UTF8 (fromTextLazy) import Text.Pandoc.Definition
src/Text/Pandoc/Writers/Docx/StyleMap.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE FlexibleContexts #-} {- | Module : Text.Pandoc.Writers.Docx.StyleMap- Copyright : © 2014-2019 Jesse Rosenthal <jrosenthal@jhu.edu>,- 2014-2019 John MacFarlane <jgm@berkeley.edu>,+ Copyright : © 2014-2020 Jesse Rosenthal <jrosenthal@jhu.edu>,+ 2014-2020 John MacFarlane <jgm@berkeley.edu>, 2015-2019 Nikolay Yakimov <root@livid.pp.ru> License : GNU GPL, version 2 or above @@ -30,7 +29,6 @@ import qualified Data.Text as T import Data.String import Data.Char (isSpace)-import Prelude data StyleMaps = StyleMaps { smCharStyle :: CharStyleNameMap, smParaStyle :: ParaStyleNameMap } type ParaStyleNameMap = M.Map ParaStyleName ParStyle
src/Text/Pandoc/Writers/DokuWiki.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Writers.DokuWiki- Copyright : Copyright (C) 2008-2019 John MacFarlane+ Copyright : Copyright (C) 2008-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : Clare Macrae <clare.macrae@googlemail.com>@@ -23,7 +22,6 @@ -} module Text.Pandoc.Writers.DokuWiki ( writeDokuWiki ) where-import Prelude import Control.Monad (zipWithM) import Control.Monad.Reader (ReaderT, asks, local, runReaderT) import Control.Monad.State.Strict (StateT, evalStateT)@@ -31,7 +29,7 @@ import Data.List (intersect, transpose) import Data.Text (Text) import qualified Data.Text as T-import Text.Pandoc.Class (PandocMonad, report)+import Text.Pandoc.Class.PandocMonad (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.ImageSize import Text.Pandoc.Logging
src/Text/Pandoc/Writers/EPUB.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE PatternGuards #-}@@ -6,7 +5,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {- | Module : Text.Pandoc.Writers.EPUB- Copyright : Copyright (C) 2010-2019 John MacFarlane+ Copyright : Copyright (C) 2010-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -16,7 +15,6 @@ Conversion of 'Pandoc' documents to EPUB. -} module Text.Pandoc.Writers.EPUB ( writeEPUB2, writeEPUB3 ) where-import Prelude import Codec.Archive.Zip (Entry, addEntryToArchive, eRelativePath, emptyArchive, fromArchive, fromEntry, toEntry) import Control.Applicative ( (<|>) )@@ -37,8 +35,9 @@ import System.FilePath (takeExtension, takeFileName, makeRelative) import Text.HTML.TagSoup (Tag (TagOpen), fromAttrib, parseTags) import Text.Pandoc.Builder (fromList, setMeta)-import Text.Pandoc.Class (PandocMonad, report)-import qualified Text.Pandoc.Class as P+import Text.Pandoc.Class.PandocMonad (PandocMonad, report)+import qualified Text.Pandoc.Class.PandocPure as P+import qualified Text.Pandoc.Class.PandocMonad as P import Data.Time import Text.Pandoc.Definition import Text.Pandoc.Error@@ -595,7 +594,8 @@ <> cssvars True <> vars } pdoc where (pdoc, bodyType) = case bs of- (Header _ (_,_,kvs) xs : _) ->+ (Div (_,"section":_,kvs)+ (Header _ _ xs : _) : _) -> -- remove notes or we get doubled footnotes (Pandoc (setMeta "title" (walk removeNote $ fromList xs) nullMeta) bs,
src/Text/Pandoc/Writers/FB2.hs view
@@ -1,10 +1,9 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE PatternGuards #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Writers.FB2 Copyright : Copyright (C) 2011-2012 Sergey Astanin- 2012-2019 John MacFarlane+ 2012-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane@@ -19,7 +18,6 @@ -} module Text.Pandoc.Writers.FB2 (writeFB2) where -import Prelude import Control.Monad (zipWithM) import Control.Monad.Except (catchError) import Control.Monad.State.Strict (StateT, evalStateT, get, gets, lift, liftM, modify)@@ -36,8 +34,8 @@ import qualified Text.XML.Light.Cursor as XC import qualified Text.XML.Light.Input as XI -import Text.Pandoc.Class (PandocMonad, report)-import qualified Text.Pandoc.Class as P+import Text.Pandoc.Class.PandocMonad (PandocMonad, report)+import qualified Text.Pandoc.Class.PandocMonad as P import Text.Pandoc.Definition import Text.Pandoc.Logging import Text.Pandoc.Options (HTMLMathMethod (..), WriterOptions (..), def)
src/Text/Pandoc/Writers/HTML.hs view
@@ -1,11 +1,10 @@ {-# LANGUAGE MultiWayIf #-}-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Writers.HTML- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -39,7 +38,6 @@ import Network.URI (URI (..), parseURIReference) import Numeric (showHex) import Text.DocLayout (render, literal)-import Prelude import Text.Blaze.Internal (MarkupM (Empty), customLeaf, customParent) import Text.DocTemplates (FromContext (lookupContext), Context (..)) import Text.Blaze.Html hiding (contents)@@ -63,7 +61,8 @@ import Text.Blaze.Html.Renderer.Text (renderHtml) import qualified Text.Blaze.XHtml1.Transitional as H import qualified Text.Blaze.XHtml1.Transitional.Attributes as A-import Text.Pandoc.Class (PandocMonad, report, runPure)+import Text.Pandoc.Class.PandocMonad (PandocMonad, report)+import Text.Pandoc.Class.PandocPure (runPure) import Text.Pandoc.Error import Text.Pandoc.Logging import Text.Pandoc.MIME (mediaCategory)@@ -1310,4 +1309,3 @@ html5 <- gets stHtml5 return $ f == Format "html" || ((html5 && f == Format "html5") || f == Format "html4")-
src/Text/Pandoc/Writers/Haddock.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {- |@@ -15,12 +14,11 @@ Haddock: <http://www.haskell.org/haddock/doc/html/> -} module Text.Pandoc.Writers.Haddock (writeHaddock) where-import Prelude import Control.Monad.State.Strict import Data.Default import Data.Text (Text) import qualified Data.Text as T-import Text.Pandoc.Class (PandocMonad, report)+import Text.Pandoc.Class.PandocMonad (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.Logging import Text.Pandoc.Options
src/Text/Pandoc/Writers/ICML.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-}@@ -6,7 +5,7 @@ {- | Module : Text.Pandoc.Writers.ICML- Copyright : Copyright (C) 2013-2019 github.com/mb21+ Copyright : Copyright (C) 2013-2020 github.com/mb21 License : GNU GPL, version 2 or above Stability : alpha@@ -18,7 +17,6 @@ into InDesign with File -> Place. -} module Text.Pandoc.Writers.ICML (writeICML) where-import Prelude import Control.Monad.Except (catchError) import Control.Monad.State.Strict import Data.List (intersperse)@@ -26,8 +24,7 @@ import qualified Data.Set as Set import qualified Data.Text as Text import Data.Text (Text)-import Text.Pandoc.Class (PandocMonad, report)-import qualified Text.Pandoc.Class as P+import Text.Pandoc.Class.PandocMonad (PandocMonad, fetchItem, report) import Text.Pandoc.Definition import Text.Pandoc.ImageSize import Text.Pandoc.Logging@@ -552,7 +549,7 @@ imageICML :: PandocMonad m => WriterOptions -> Style -> Attr -> Target -> WS m (Doc Text) imageICML opts style attr (src, _) = do imgS <- catchError- (do (img, _) <- P.fetchItem src+ (do (img, _) <- fetchItem src case imageSize opts img of Right size -> return size Left msg -> do
src/Text/Pandoc/Writers/Ipynb.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {- | Module : Text.Pandoc.Writers.Ipynb- Copyright : Copyright (C) 2019 John MacFarlane+ Copyright : Copyright (C) 2019-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -15,7 +14,6 @@ -} module Text.Pandoc.Writers.Ipynb ( writeIpynb ) where-import Prelude import Control.Monad.State import qualified Data.Map as M import Data.Maybe (catMaybes, fromMaybe)@@ -24,7 +22,7 @@ import Data.Ipynb as Ipynb import Text.Pandoc.Walk (walkM) import qualified Text.Pandoc.Builder as B-import Text.Pandoc.Class+import Text.Pandoc.Class.PandocMonad import Text.Pandoc.Logging import Data.Text (Text) import qualified Data.Text as T
src/Text/Pandoc/Writers/JATS.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ViewPatterns #-}@@ -21,7 +20,6 @@ , writeJatsPublishing , writeJatsArticleAuthoring ) where-import Prelude import Control.Monad.Reader import Control.Monad.State import Data.Generics (everywhere, mkT)@@ -31,7 +29,7 @@ import Data.Time (toGregorian, Day, parseTimeM, defaultTimeLocale, formatTime) import qualified Data.Text as T import Data.Text (Text)-import Text.Pandoc.Class (PandocMonad, report)+import Text.Pandoc.Class.PandocMonad (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.Highlighting (languages, languagesByExtension) import Text.Pandoc.Logging
src/Text/Pandoc/Writers/Jira.hs view
@@ -1,9 +1,8 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.Writers.Jira- Copyright : © 2010-2019 Albert Krewinkel, John MacFarlane+ Copyright : © 2010-2020 Albert Krewinkel, John MacFarlane License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -16,14 +15,13 @@ <https://jira.atlassian.com/secure/WikiRendererHelpAction.jspa?section=all> -} module Text.Pandoc.Writers.Jira ( writeJira ) where-import Prelude import Control.Monad.Reader (ReaderT, ask, asks, runReaderT) import Control.Monad.State.Strict (StateT, evalStateT, gets, modify) import Data.Foldable (find) import Data.Text (Text) import Text.Jira.Parser (plainText) import Text.Jira.Printer (prettyBlocks, prettyInlines)-import Text.Pandoc.Class (PandocMonad)+import Text.Pandoc.Class.PandocMonad (PandocMonad) import Text.Pandoc.Definition import Text.Pandoc.Options (WriterOptions (writerTemplate, writerWrapText), WrapOption (..))
src/Text/Pandoc/Writers/LaTeX.hs view
@@ -1,11 +1,10 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PatternGuards #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Writers.LaTeX- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -18,7 +17,6 @@ writeLaTeX , writeBeamer ) where-import Prelude import Control.Applicative ((<|>)) import Control.Monad.State.Strict import Data.Monoid (Any(..))@@ -33,7 +31,7 @@ import Text.DocTemplates (FromContext(lookupContext), renderTemplate, Val(..), Context(..)) import Text.Pandoc.BCP47 (Lang (..), getLang, renderLang)-import Text.Pandoc.Class (PandocMonad, report, toLang)+import Text.Pandoc.Class.PandocMonad (PandocMonad, report, toLang) import Text.Pandoc.Definition import Text.Pandoc.Highlighting (formatLaTeXBlock, formatLaTeXInline, highlight, styleToLaTeX, toListingsLanguage)
src/Text/Pandoc/Writers/Man.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Writers.Man- Copyright : Copyright (C) 2007-2019 John MacFarlane+ Copyright : Copyright (C) 2007-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -14,14 +13,13 @@ -} module Text.Pandoc.Writers.Man ( writeMan ) where-import Prelude import Control.Monad.State.Strict import Data.List (intersperse) import Data.Maybe (fromMaybe) import Data.Text (Text) import qualified Data.Text as T import Text.Pandoc.Builder (deleteMeta)-import Text.Pandoc.Class (PandocMonad, report)+import Text.Pandoc.Class.PandocMonad (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.Logging import Text.Pandoc.Options
src/Text/Pandoc/Writers/Markdown.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-}@@ -6,7 +5,7 @@ {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Writers.Markdown- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -18,7 +17,6 @@ Markdown: <http://daringfireball.net/projects/markdown/> -} module Text.Pandoc.Writers.Markdown (writeMarkdown, writePlain) where-import Prelude import Control.Monad.Reader import Control.Monad.State.Strict import Data.Char (isAlphaNum)@@ -32,7 +30,7 @@ import qualified Data.Text as T import Network.HTTP (urlEncode) import Text.HTML.TagSoup (Tag (..), isTagText, parseTags)-import Text.Pandoc.Class (PandocMonad, report)+import Text.Pandoc.Class.PandocMonad (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.Logging import Text.Pandoc.Options
src/Text/Pandoc/Writers/Math.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} module Text.Pandoc.Writers.Math ( texMathToInlines@@ -8,9 +7,8 @@ ) where -import Prelude import qualified Data.Text as T-import Text.Pandoc.Class+import Text.Pandoc.Class.PandocMonad import Text.Pandoc.Definition import Text.Pandoc.Logging import Text.TeXMath (DisplayType (..), Exp, readTeX, writePandoc)
src/Text/Pandoc/Writers/MediaWiki.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Writers.MediaWiki- Copyright : Copyright (C) 2008-2019 John MacFarlane+ Copyright : Copyright (C) 2008-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -15,14 +14,13 @@ MediaWiki: <http://www.mediawiki.org/wiki/MediaWiki> -} module Text.Pandoc.Writers.MediaWiki ( writeMediaWiki, highlightingLangs ) where-import Prelude import Control.Monad.Reader import Control.Monad.State.Strict import Data.Maybe (fromMaybe) import qualified Data.Set as Set import Data.Text (Text) import qualified Data.Text as T-import Text.Pandoc.Class (PandocMonad, report)+import Text.Pandoc.Class.PandocMonad (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.ImageSize import Text.Pandoc.Logging
src/Text/Pandoc/Writers/Ms.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Writers.Ms- Copyright : Copyright (C) 2007-2019 John MacFarlane+ Copyright : Copyright (C) 2007-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -21,7 +20,6 @@ -} module Text.Pandoc.Writers.Ms ( writeMs ) where-import Prelude import Control.Monad.State.Strict import Data.Char (isLower, isUpper, ord) import Data.List (intercalate, intersperse)@@ -33,7 +31,7 @@ import Skylighting import System.FilePath (takeExtension) import Text.Pandoc.Asciify (toAsciiChar)-import Text.Pandoc.Class (PandocMonad, report)+import Text.Pandoc.Class.PandocMonad (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.Highlighting import Text.Pandoc.ImageSize@@ -216,7 +214,7 @@ setFirstPara contents <- blockListToMs opts blocks setFirstPara- return $ literal ".RS" $$ contents $$ literal ".RE"+ return $ literal ".QS" $$ contents $$ literal ".QE" blockToMs opts (Table caption alignments widths headers rows) = let aligncode AlignLeft = "l" aligncode AlignRight = "r"@@ -321,8 +319,9 @@ rest' <- liftM vcat $ mapM (\item -> blockToMs opts item) rest first' <- blockToMs opts first- return $ first' $$ literal ".RS" $$ rest' $$ literal ".RE"- return $ nowrap (literal ".IP " <> doubleQuotes labelText) $$ contents+ return $ first' $$ literal ".RS 3" $$ rest' $$ literal ".RE"+ return $ nowrap (literal ".IP " <> doubleQuotes labelText <> " 3") $$+ contents -- | Convert list of Pandoc block elements to ms. blockListToMs :: PandocMonad m@@ -400,7 +399,7 @@ case res of Left il -> do contents <- inlineToMs opts il- return $ cr <> literal ".RS" $$ contents $$ literal ".RE"+ return $ cr <> literal ".RS 3" $$ contents $$ literal ".RE" Right r -> return $ cr <> literal ".EQ" $$ literal r $$ literal ".EN" <> cr inlineToMs _ il@(RawInline f str)
src/Text/Pandoc/Writers/Muse.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Writers.Muse- Copyright : Copyright (C) 2017-2019 Alexander Krotov+ Copyright : Copyright (C) 2017-2020 Alexander Krotov License : GNU GPL, version 2 or above Maintainer : Alexander Krotov <ilabdsf@gmail.com>@@ -26,7 +25,6 @@ even though it is supported only in Emacs Muse. -} module Text.Pandoc.Writers.Muse (writeMuse) where-import Prelude import Control.Monad.Except (throwError) import Control.Monad.Reader import Control.Monad.State.Strict@@ -37,7 +35,7 @@ import qualified Data.Text as T import Data.Text (Text) import System.FilePath (takeExtension)-import Text.Pandoc.Class (PandocMonad)+import Text.Pandoc.Class.PandocMonad (PandocMonad) import Text.Pandoc.Definition import Text.Pandoc.Error import Text.Pandoc.ImageSize
src/Text/Pandoc/Writers/Native.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Writers.Native- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -13,10 +12,9 @@ -} module Text.Pandoc.Writers.Native ( writeNative ) where-import Prelude import Data.List (intersperse) import Data.Text (Text)-import Text.Pandoc.Class (PandocMonad)+import Text.Pandoc.Class.PandocMonad (PandocMonad) import Text.Pandoc.Definition import Text.Pandoc.Options (WrapOption (..), WriterOptions (..)) import Text.DocLayout
src/Text/Pandoc/Writers/ODT.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Writers.ODT- Copyright : Copyright (C) 2008-2019 John MacFarlane+ Copyright : Copyright (C) 2008-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -13,7 +12,6 @@ Conversion of 'Pandoc' documents to ODT. -} module Text.Pandoc.Writers.ODT ( writeODT ) where-import Prelude import Codec.Archive.Zip import Control.Monad.Except (catchError) import Control.Monad.State.Strict@@ -26,8 +24,8 @@ import Data.Time import System.FilePath (takeDirectory, takeExtension, (<.>)) import Text.Pandoc.BCP47 (Lang (..), getLang, renderLang)-import Text.Pandoc.Class (PandocMonad, report, toLang)-import qualified Text.Pandoc.Class as P+import Text.Pandoc.Class.PandocMonad (PandocMonad, report, toLang)+import qualified Text.Pandoc.Class.PandocMonad as P import Text.Pandoc.Definition import Text.Pandoc.ImageSize import Text.Pandoc.Logging
src/Text/Pandoc/Writers/OOXML.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Writers.OOXML- Copyright : Copyright (C) 2012-2019 John MacFarlane+ Copyright : Copyright (C) 2012-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -24,7 +23,6 @@ , fitToPage ) where -import Prelude import Codec.Archive.Zip import Control.Monad.Reader import Control.Monad.Except (throwError)@@ -34,7 +32,7 @@ import qualified Data.ByteString.Lazy.Char8 as BL8 import Data.Maybe (mapMaybe) import qualified Data.Text as T-import Text.Pandoc.Class (PandocMonad)+import Text.Pandoc.Class.PandocMonad (PandocMonad) import qualified Text.Pandoc.UTF8 as UTF8 import Text.XML.Light as XML
src/Text/Pandoc/Writers/OPML.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE CPP #-} {- | Module : Text.Pandoc.Writers.OPML- Copyright : Copyright (C) 2013-2019 John MacFarlane+ Copyright : Copyright (C) 2013-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -13,11 +12,10 @@ Conversion of 'Pandoc' documents to OPML XML. -} module Text.Pandoc.Writers.OPML ( writeOPML) where-import Prelude import Data.Text (Text) import qualified Data.Text as T import qualified Text.Pandoc.Builder as B-import Text.Pandoc.Class (PandocMonad)+import Text.Pandoc.Class.PandocMonad (PandocMonad) import Data.Time import Text.Pandoc.Definition import Text.Pandoc.Options
src/Text/Pandoc/Writers/OpenDocument.hs view
@@ -1,11 +1,10 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PatternGuards #-} {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Writers.OpenDocument- Copyright : Copyright (C) 2008-2019 Andrea Rossato and John MacFarlane+ Copyright : Copyright (C) 2008-2020 Andrea Rossato and John MacFarlane License : GNU GPL, version 2 or above Maintainer : Andrea Rossato <andrea.rossato@ing.unitn.it>@@ -15,7 +14,6 @@ Conversion of 'Pandoc' documents to OpenDocument XML. -} module Text.Pandoc.Writers.OpenDocument ( writeOpenDocument ) where-import Prelude import Control.Arrow ((***), (>>>)) import Control.Monad.State.Strict hiding (when) import Data.Char (chr)@@ -27,8 +25,8 @@ import Data.Text (Text) import qualified Data.Text as T import Text.Pandoc.BCP47 (Lang (..), parseBCP47)-import Text.Pandoc.Class (PandocMonad, report, translateTerm,- setTranslations, toLang)+import Text.Pandoc.Class.PandocMonad (PandocMonad, report, translateTerm,+ setTranslations, toLang) import Text.Pandoc.Definition import Text.Pandoc.Logging import Text.Pandoc.Options
src/Text/Pandoc/Writers/Org.hs view
@@ -1,10 +1,9 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Writers.Org Copyright : © 2010-2015 Puneeth Chaganti <punchagan@gmail.com>- 2010-2019 John MacFarlane <jgm@berkeley.edu>- 2016-2019 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>+ 2010-2020 John MacFarlane <jgm@berkeley.edu>+ 2016-2020 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de> License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -16,13 +15,12 @@ Org-Mode: <http://orgmode.org> -} module Text.Pandoc.Writers.Org (writeOrg) where-import Prelude import Control.Monad.State.Strict import Data.Char (isAlphaNum) import Data.List (intersect, intersperse, partition, transpose) import Data.Text (Text) import qualified Data.Text as T-import Text.Pandoc.Class (PandocMonad, report)+import Text.Pandoc.Class.PandocMonad (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.Logging import Text.Pandoc.Options
src/Text/Pandoc/Writers/Powerpoint.hs view
@@ -1,7 +1,6 @@-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.Writers.Powerpoint- Copyright : Copyright (C) 2017-2019 Jesse Rosenthal+ Copyright : Copyright (C) 2017-2020 Jesse Rosenthal License : GNU GPL, version 2 or above Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>@@ -22,11 +21,10 @@ module Text.Pandoc.Writers.Powerpoint (writePowerpoint) where -import Prelude import Codec.Archive.Zip import Text.Pandoc.Definition import Text.Pandoc.Walk-import Text.Pandoc.Class (PandocMonad, report)+import Text.Pandoc.Class.PandocMonad (PandocMonad, report) import Text.Pandoc.Options (WriterOptions) import Text.Pandoc.Writers.Shared (fixDisplayMath) import Text.Pandoc.Writers.Powerpoint.Presentation (documentToPresentation)
src/Text/Pandoc/Writers/Powerpoint/Output.hs view
@@ -1,9 +1,8 @@ {-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE PatternGuards #-} {- | Module : Text.Pandoc.Writers.Powerpoint.Output- Copyright : Copyright (C) 2017-2019 Jesse Rosenthal+ Copyright : Copyright (C) 2017-2020 Jesse Rosenthal License : GNU GPL, version 2 or above Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>@@ -17,7 +16,6 @@ module Text.Pandoc.Writers.Powerpoint.Output ( presentationToArchive ) where -import Prelude import Control.Monad.Except (throwError, catchError) import Control.Monad.Reader import Control.Monad.State@@ -33,9 +31,9 @@ import Text.XML.Light import Text.Pandoc.Definition import qualified Text.Pandoc.UTF8 as UTF8-import Text.Pandoc.Class (PandocMonad)+import Text.Pandoc.Class.PandocMonad (PandocMonad) import Text.Pandoc.Error (PandocError(..))-import qualified Text.Pandoc.Class as P+import qualified Text.Pandoc.Class.PandocMonad as P import Text.Pandoc.Options import Text.Pandoc.MIME import qualified Data.ByteString.Lazy as BL
src/Text/Pandoc/Writers/Powerpoint/Presentation.hs view
@@ -1,11 +1,10 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PatternGuards #-} {-# LANGUAGE ViewPatterns #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {- | Module : Text.Pandoc.Writers.Powerpoint.Presentation- Copyright : Copyright (C) 2017-2019 Jesse Rosenthal+ Copyright : Copyright (C) 2017-2020 Jesse Rosenthal License : GNU GPL, version 2 or above Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>@@ -43,7 +42,6 @@ ) where -import Prelude import Control.Monad.Reader import Control.Monad.State import Data.List (intercalate)
src/Text/Pandoc/Writers/RST.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Writers.RST- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -15,7 +14,6 @@ reStructuredText: <http://docutils.sourceforge.net/rst.html> -} module Text.Pandoc.Writers.RST ( writeRST, flatten ) where-import Prelude import Control.Monad.State.Strict import Data.Char (isSpace) import Data.List (transpose, intersperse)@@ -23,7 +21,7 @@ import qualified Data.Text as T import Data.Text (Text) import qualified Text.Pandoc.Builder as B-import Text.Pandoc.Class (PandocMonad, report)+import Text.Pandoc.Class.PandocMonad (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.ImageSize import Text.Pandoc.Logging
src/Text/Pandoc/Writers/RTF.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Writers.RTF- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -14,7 +13,6 @@ -} module Text.Pandoc.Writers.RTF ( writeRTF ) where-import Prelude import Control.Monad.Except (catchError, throwError) import Control.Monad import qualified Data.ByteString as B@@ -22,8 +20,8 @@ import qualified Data.Map as M import Data.Text (Text) import qualified Data.Text as T-import Text.Pandoc.Class (PandocMonad, report)-import qualified Text.Pandoc.Class as P+import Text.Pandoc.Class.PandocMonad (PandocMonad, report)+import qualified Text.Pandoc.Class.PandocMonad as P import Text.Pandoc.Definition import Text.Pandoc.Error import Text.Pandoc.ImageSize
src/Text/Pandoc/Writers/Roff.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Writers.Roff- Copyright : Copyright (C) 2007-2019 John MacFarlane+ Copyright : Copyright (C) 2007-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -21,7 +20,6 @@ , escapeString , withFontFeature ) where-import Prelude import Data.Char (ord, isAscii) import Control.Monad.State.Strict import qualified Data.Map as Map@@ -29,7 +27,7 @@ import qualified Data.Text as Text import Data.String import Data.Maybe (fromMaybe, isJust, catMaybes)-import Text.Pandoc.Class (PandocMonad)+import Text.Pandoc.Class.PandocMonad (PandocMonad) import Text.Pandoc.Definition import Text.DocLayout import Text.Printf (printf)
@@ -1,10 +1,9 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Writers.Shared- Copyright : Copyright (C) 2013-2019 John MacFarlane+ Copyright : Copyright (C) 2013-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -37,7 +36,6 @@ , endsWithPlain ) where-import Prelude import Safe (lastMay) import qualified Data.ByteString.Lazy as BL import Data.Maybe (fromMaybe, isNothing)
src/Text/Pandoc/Writers/TEI.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PatternGuards #-} {- | Module : Text.Pandoc.Writers.Docbook- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -13,10 +12,9 @@ Conversion of 'Pandoc' documents to Docbook XML. -} module Text.Pandoc.Writers.TEI (writeTEI) where-import Prelude import Data.Text (Text) import qualified Data.Text as T-import Text.Pandoc.Class (PandocMonad, report)+import Text.Pandoc.Class.PandocMonad (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.Highlighting (languages, languagesByExtension) import Text.Pandoc.ImageSize
src/Text/Pandoc/Writers/Texinfo.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- | Module : Text.Pandoc.Writers.Texinfo- Copyright : Copyright (C) 2008-2019 John MacFarlane+ Copyright : Copyright (C) 2008-2020 John MacFarlane 2012 Peter Wang License : GNU GPL, version 2 or above @@ -13,7 +12,6 @@ Conversion of 'Pandoc' format into Texinfo. -} module Text.Pandoc.Writers.Texinfo ( writeTexinfo ) where-import Prelude import Control.Monad.Except (throwError) import Control.Monad.State.Strict import Data.Char (chr, ord)@@ -24,7 +22,7 @@ import qualified Data.Text as T import Network.URI (unEscapeString) import System.FilePath-import Text.Pandoc.Class (PandocMonad, report)+import Text.Pandoc.Class.PandocMonad (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.Error import Text.Pandoc.ImageSize
src/Text/Pandoc/Writers/Textile.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Writers.Textile- Copyright : Copyright (C) 2010-2019 John MacFarlane+ Copyright : Copyright (C) 2010-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -15,12 +14,11 @@ Textile: <http://thresholdstate.com/articles/4312/the-textile-reference-manual> -} module Text.Pandoc.Writers.Textile ( writeTextile ) where-import Prelude import Control.Monad.State.Strict import Data.Char (isSpace) import Data.Text (Text) import qualified Data.Text as T-import Text.Pandoc.Class (PandocMonad, report)+import Text.Pandoc.Class.PandocMonad (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.ImageSize import Text.Pandoc.Logging
src/Text/Pandoc/Writers/XWiki.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {- Copyright (C) 2008-2017 John MacFarlane <jgm@berkeley.edu>@@ -34,12 +33,11 @@ -} module Text.Pandoc.Writers.XWiki ( writeXWiki ) where-import Prelude import Control.Monad.Reader (ReaderT, asks, local, runReaderT) import qualified Data.Set as Set import qualified Data.Text as Text import Data.Text (Text, intercalate, replace, split)-import Text.Pandoc.Class (PandocMonad, report)+import Text.Pandoc.Class.PandocMonad (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.Logging import Text.Pandoc.Options
src/Text/Pandoc/Writers/ZimWiki.hs view
@@ -1,9 +1,9 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Writers.ZimWiki- Copyright : Copyright (C) 2008-2019 John MacFarlane, 2017-2019 Alex Ivkin+ Copyright : © 2008-2020 John MacFarlane,+ 2017-2019 Alex Ivkin License : GNU GPL, version 2 or above Maintainer : Alex Ivkin <alex@ivkin.net>@@ -16,7 +16,6 @@ -} module Text.Pandoc.Writers.ZimWiki ( writeZimWiki ) where-import Prelude import Control.Monad (zipWithM) import Control.Monad.State.Strict (StateT, evalStateT, gets, modify) import Data.Default (Default (..))@@ -26,7 +25,7 @@ import Data.Maybe (fromMaybe) import Data.Text (Text) import qualified Data.Text as T-import Text.Pandoc.Class (PandocMonad, report)+import Text.Pandoc.Class.PandocMonad (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.ImageSize import Text.Pandoc.Logging
src/Text/Pandoc/XML.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.XML- Copyright : Copyright (C) 2006-2019 John MacFarlane+ Copyright : Copyright (C) 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -25,7 +24,6 @@ html5Attributes, rdfaAttributes ) where -import Prelude import Data.Char (isAscii, isSpace, ord) import Data.Text (Text) import qualified Data.Text as T@@ -149,12 +147,14 @@ , "accept-charset" , "accesskey" , "action"+ , "allow" , "allowfullscreen" , "allowpaymentrequest" , "allowusermedia" , "alt" , "as" , "async"+ , "autocapitalize" , "autocomplete" , "autofocus" , "autoplay"@@ -172,6 +172,7 @@ , "crossorigin" , "data" , "datetime"+ , "decoding" , "default" , "defer" , "dir"@@ -180,6 +181,7 @@ , "download" , "draggable" , "enctype"+ , "enterkeyhint" , "for" , "form" , "formaction"@@ -195,6 +197,8 @@ , "hreflang" , "http-equiv" , "id"+ , "imagesizes"+ , "imagesrcset" , "inputmode" , "integrity" , "is"@@ -208,6 +212,7 @@ , "label" , "lang" , "list"+ , "loading" , "loop" , "low" , "manifest"
stack.yaml view
@@ -20,7 +20,7 @@ - regex-pcre-builtin-0.95.0.8.8.35 - doclayout-0.3 - emojis-0.1-- jira-wiki-markup-1.0.0+- jira-wiki-markup-1.1.3 - HsYAML-0.2.0.0 - HsYAML-aeson-0.2.0.0 - doctemplates-0.8.1
test/Tests/Command.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE NoImplicitPrelude #-} {- | Module : Tests.Command- Copyright : © 2006-2019 John MacFarlane+ Copyright : © 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley@edu>
test/Tests/Helpers.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeSynonymInstances #-} {- | Module : Tests.Helpers- Copyright : © 2006-2019 John MacFarlane+ Copyright : © 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley@edu>
test/Tests/Lua.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Tests.Lua- Copyright : © 2017-2019 Albert Krewinkel+ Copyright : © 2017-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <albert@zeitkraut.de>
test/Tests/Lua/Module.hs view
@@ -1,6 +1,6 @@ {- | Module : Tests.Lua.Module-Copyright : © 2019 Albert Krewinkel+Copyright : © 2019-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <albert@zeitkraut.de>
test/Tests/Old.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE NoImplicitPrelude #-} {- | Module : Tests.Old- Copyright : © 2006-2019 John MacFarlane+ Copyright : © 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley@edu>
test/Tests/Readers/Creole.hs view
@@ -3,7 +3,7 @@ {- | Module : Tests.Readers.Creole Copyright : © 2017 Sascha Wilde- 2017-2019 John MacFarlane+ 2017-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : Sascha Wilde <wilde@sha-bang.de>
test/Tests/Readers/Docx.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Tests.Readers.Docx- Copyright : © 2017-2019 Jesse Rosenthal, John MacFarlane+ Copyright : © 2017-2020 Jesse Rosenthal, John MacFarlane License : GNU GPL, version 2 or above Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>
test/Tests/Readers/DokuWiki.hs view
@@ -3,7 +3,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {- | Module : Tests.Readers.DokuWiki- Copyright : © 2018-2019 Alexander Krotov+ Copyright : © 2018-2020 Alexander Krotov License : GNU GPL, version 2 or above Maintainer : Alexander Krotov
test/Tests/Readers/EPUB.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE NoImplicitPrelude #-} {- | Module : Tests.Readers.EPUB- Copyright : © 2006-2019 John MacFarlane+ Copyright : © 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.eu>
test/Tests/Readers/FB2.hs view
@@ -1,10 +1,10 @@ {-# LANGUAGE NoImplicitPrelude #-} {- | Module : Tests.Readers.FB2- Copyright : © 2018-2019 Alexander Krotov+ Copyright : © 2018-2020 Alexander Krotov License : GNU GPL, version 2 or above - Maintainer : © 2018-2019 Alexander Krotov <ilabdsf@gmail.com>+ Maintainer : © 2018-2020 Alexander Krotov <ilabdsf@gmail.com> Stability : alpha Portability : portable
test/Tests/Readers/HTML.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Tests.Readers.HTML- Copyright : © 2006-2019 John MacFarlane+ Copyright : © 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>
test/Tests/Readers/Jira.hs view
@@ -3,7 +3,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {- | Module : Tests.Readers.Jira- Copyright : © 2019 Albert Krewinel+ Copyright : © 2019-2020 Albert Krewinel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <tarleb@zeitkraut.de>@@ -77,6 +77,11 @@ simpleTable [] [ [para "language", para "haskell", para "lua"] , [para "type", para "static", para "dynamic"]]++ , "table after paragraph" =:+ "*tabletest*\n||Name|\n|Test|\n" =?>+ para (strong "tabletest") <>+ simpleTable [para "Name"] [[para "Test"]] ] , testGroup "inlines"@@ -96,6 +101,10 @@ "HCO ~3~^-^" =?> para ("HCO " <> subscript "3" <> superscript "-") + , "color" =:+ "This is {color:red}red{color}." =?>+ para ("This is " <> spanWith ("", [], [("color", "red")]) "red" <> ".")+ , "linebreak" =: "first\nsecond" =?> para ("first" <> linebreak <> "second")@@ -110,5 +119,9 @@ , "HTML entity" =: "me & you" =?> para "me & you"++ , "non-strikeout dashes" =:+ "20.09-15 2-678" =?>+ para "20.09-15 2-678" ] ]
test/Tests/Readers/LaTeX.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Tests.Readers.LaTeX- Copyright : © 2006-2019 John MacFarlane+ Copyright : © 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>
test/Tests/Readers/Man.hs view
@@ -2,7 +2,7 @@ {- | Module : Tests.Readers.Man Copyright : © 2018-2019 Yan Pas <yanp.bugz@gmail.com>,- 2018-2019 John MacFarlane+ 2018-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -80,7 +80,7 @@ "\\-\\ \\\\\\[lq]\\[rq]\\[em]\\[en]\\*(lq\\*(rq" =?>para (text "- \\“”—–“”") , "replace2" =:- "\\t\\e\\`\\^\\|\\'" =?>para (text "\\`\8202\8198`")+ "\\t\\e\\`\\^\\|\\'" =?>para (text "\\`\8202\8198'") , "comment with \\\"" =: "Foo \\\" bar\n" =?>para (text "Foo") , "comment with \\#" =:
test/Tests/Readers/Markdown.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Tests.Readers.Markdown- Copyright : © 2006-2019 John MacFarlane+ Copyright : © 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>
test/Tests/Readers/Muse.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Tests.Readers.Muse- Copyright : © 2017-2019 Alexander Krotov+ Copyright : © 2017-2020 Alexander Krotov License : GNU GPL, version 2 or above Maintainer : Alexander Krotov <ilabdsf@gmail.com>
test/Tests/Readers/Odt.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Tests.Readers.Odt- Copyright : © 2015-2019 John MacFarlane+ Copyright : © 2015-2020 John MacFarlane 2015 Martin Linnemann License : GNU GPL, version 2 or above
test/Tests/Readers/Org.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Tests.Shared- Copyright : © 2014-2019 Albert Krewinkel+ Copyright : © 2014-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <albert@zeitkraut.de>
test/Tests/Readers/Org/Block.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Tests.Readers.Org.Block- Copyright : © 2014-2019 Albert Krewinkel+ Copyright : © 2014-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <albert@zeitkraut.de>
test/Tests/Readers/Org/Block/CodeBlock.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Tests.Readers.Org.Block.CodeBlock- Copyright : © 2014-2019 Albert Krewinkel+ Copyright : © 2014-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <albert@zeitkraut.de>
test/Tests/Readers/Org/Block/Figure.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Tests.Readers.Org.Block.Figure- Copyright : © 2014-2019 Albert Krewinkel+ Copyright : © 2014-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <albert@zeitkraut.de>
test/Tests/Readers/Org/Block/Header.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Tests.Readers.Org.Block.Header- Copyright : © 2014-2019 Albert Krewinkel+ Copyright : © 2014-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <albert@zeitkraut.de>
test/Tests/Readers/Org/Block/List.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Tests.Readers.Org.Block.Header- Copyright : © 2014-2019 Albert Krewinkel+ Copyright : © 2014-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <albert@zeitkraut.de>
test/Tests/Readers/Org/Block/Table.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Tests.Readers.Org.Block.Table- Copyright : © 2014-2019 Albert Krewinkel+ Copyright : © 2014-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <albert@zeitkraut.de>
test/Tests/Readers/Org/Directive.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Tests.Readers.Org.Directive- Copyright : © 2014-2019 Albert Krewinkel+ Copyright : © 2014-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <albert@zeitkraut.de>
test/Tests/Readers/Org/Inline.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Tests.Readers.Org.Inline- Copyright : © 2014-2019 Albert Krewinkel+ Copyright : © 2014-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <albert@zeitkraut.de>
test/Tests/Readers/Org/Inline/Citation.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Tests.Readers.Org.Inline.Citation- Copyright : © 2014-2019 Albert Krewinkel+ Copyright : © 2014-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <albert@zeitkraut.de>
test/Tests/Readers/Org/Inline/Note.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Tests.Readers.Org.Inline.Note- Copyright : © 2014-2019 Albert Krewinkel+ Copyright : © 2014-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <albert@zeitkraut.de>
test/Tests/Readers/Org/Inline/Smart.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Tests.Readers.Org.Inline.Smart- Copyright : © 2014-2019 Albert Krewinkel+ Copyright : © 2014-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <albert@zeitkraut.de>
test/Tests/Readers/Org/Meta.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Tests.Readers.Org.Meta- Copyright : © 2014-2019 Albert Krewinkel+ Copyright : © 2014-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <albert@zeitkraut.de>
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Tests.Readers.Org.Shared- Copyright : © 2014-2019 Albert Krewinkel+ Copyright : © 2014-2020 Albert Krewinkel License : GNU GPL, version 2 or above Maintainer : Albert Krewinkel <albert@zeitkraut.de>
test/Tests/Readers/RST.hs view
@@ -3,7 +3,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {- | Module : Tests.Readers.RST- Copyright : © 2006-2019 John MacFarlane+ Copyright : © 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>
test/Tests/Readers/Txt2Tags.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Tests.Readers.Txt2Tags- Copyright : © 2014-2019 John MacFarlane,+ Copyright : © 2014-2020 John MacFarlane, © 2014 Matthew Pickering License : GNU GPL, version 2 or above
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Tests.Shared- Copyright : © 2006-2019 John MacFarlane+ Copyright : © 2006-2020 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley@edu>
test/writer.ms view
@@ -150,12 +150,12 @@ .pdfhref M "block-quotes" .LP E-mail style:-.RS+.QS .LP This is a block quote. It is pretty short.-.RE-.RS+.QE+.QS .LP Code in a block quote: .IP@@ -174,15 +174,15 @@ item two .LP Nested block quotes:-.RS+.QS .LP nested-.RE-.RS+.QE+.QS .LP nested-.RE-.RE+.QE+.QE .LP This should not be a block quote: 2 > 1. .PP@@ -445,112 +445,112 @@ .pdfhref M "definition-lists" .LP Tight using spaces:-.IP "\f[B]apple\f[R]"+.IP "\f[B]apple\f[R]" 3 red fruit-.RS+.RS 3 .RE-.IP "\f[B]orange\f[R]"+.IP "\f[B]orange\f[R]" 3 orange fruit-.RS+.RS 3 .RE-.IP "\f[B]banana\f[R]"+.IP "\f[B]banana\f[R]" 3 yellow fruit-.RS+.RS 3 .RE .LP Tight using tabs:-.IP "\f[B]apple\f[R]"+.IP "\f[B]apple\f[R]" 3 red fruit-.RS+.RS 3 .RE-.IP "\f[B]orange\f[R]"+.IP "\f[B]orange\f[R]" 3 orange fruit-.RS+.RS 3 .RE-.IP "\f[B]banana\f[R]"+.IP "\f[B]banana\f[R]" 3 yellow fruit-.RS+.RS 3 .RE .LP Loose:-.IP "\f[B]apple\f[R]"+.IP "\f[B]apple\f[R]" 3 red fruit-.RS+.RS 3 .RE-.IP "\f[B]orange\f[R]"+.IP "\f[B]orange\f[R]" 3 orange fruit-.RS+.RS 3 .RE-.IP "\f[B]banana\f[R]"+.IP "\f[B]banana\f[R]" 3 yellow fruit-.RS+.RS 3 .RE .LP Multiple blocks with italics:-.IP "\f[B]\f[BI]apple\f[B]\f[R]"+.IP "\f[B]\f[BI]apple\f[B]\f[R]" 3 red fruit-.RS+.RS 3 .PP contains seeds, crisp, pleasant to taste .RE-.IP "\f[B]\f[BI]orange\f[B]\f[R]"+.IP "\f[B]\f[BI]orange\f[B]\f[R]" 3 orange fruit-.RS+.RS 3 .IP .nf \f[C] { orange code block } \f[] .fi-.RS+.QS .LP orange block quote-.RE+.QE .RE .LP Multiple definitions, tight:-.IP "\f[B]apple\f[R]"+.IP "\f[B]apple\f[R]" 3 red fruit-.RS+.RS 3 .RE computer-.RS+.RS 3 .RE-.IP "\f[B]orange\f[R]"+.IP "\f[B]orange\f[R]" 3 orange fruit-.RS+.RS 3 .RE bank-.RS+.RS 3 .RE .LP Multiple definitions, loose:-.IP "\f[B]apple\f[R]"+.IP "\f[B]apple\f[R]" 3 red fruit-.RS+.RS 3 .RE computer-.RS+.RS 3 .RE-.IP "\f[B]orange\f[R]"+.IP "\f[B]orange\f[R]" 3 orange fruit-.RS+.RS 3 .RE bank-.RS+.RS 3 .RE .LP Blank line after term, indented marker, alternate markers:-.IP "\f[B]apple\f[R]"+.IP "\f[B]apple\f[R]" 3 red fruit-.RS+.RS 3 .RE computer-.RS+.RS 3 .RE-.IP "\f[B]orange\f[R]"+.IP "\f[B]orange\f[R]" 3 orange fruit-.RS+.RS 3 .IP " 1." 4 sublist .IP " 2." 4@@ -930,13 +930,13 @@ .pdfhref W -D "mailto:nobody%40nowhere.net" -A "\c" \ -- "nobody\[at]nowhere.net" \&-.RS+.QS .LP Blockquoted: \c .pdfhref W -D "http://example.com/" -A "\c" \ -- "http://example.com/" \&-.RE+.QE .LP Auto-links should not occur here: \f[C]<http://example.com/>\f[R] .IP@@ -994,13 +994,13 @@ -- "links" \& and \f[C]]\f[R] verbatim characters, as well as [bracketed text]. .FE-.RS+.QS .LP Notes can go in quotes.\** .FS In quote. .FE-.RE+.QE .IP " 1." 4 And in list items.\** .FS
trypandoc/index.html view
@@ -9,10 +9,11 @@ <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> <![endif]-->- <script src="//code.jquery.com/jquery-1.11.1.min.js"></script>- <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet">- <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>- <script type="text/javascript">+ <script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>+ <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet">+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>+ <script>+"use strict"; (function($) { // http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values $.QueryString = (function(a) { if (a == "") return {};@@ -31,8 +32,9 @@ var input = $("#text").val(); var from = $("#from").val(); var to = $("#to").val();+ var standalone = $("#standalone").is(':checked') ? "1" : "0"; var href = window.location.href;- window.location.href = href.replace(/([?].*)?$/,"?" + $.param({text: input, from: from, to: to}));+ window.location.href = href.replace(/([?].*)?$/,"?" + $.param({text: input, from: from, to: to, standalone: standalone})); }; $(document).ready(function() {@@ -42,8 +44,10 @@ $("#from").val(from); var to = $.QueryString["to"] || "html"; $("#to").val(to);+ var standalone = ($.QueryString["standalone"] === "1") ? "1" : "0"+ $("#standalone").prop('checked', (standalone === "1")); if (text && text != "") {- $.getJSON("/cgi-bin/trypandoc", { from: from, to: to, text: text },+ $.getJSON("/cgi-bin/trypandoc", { from: from, to: to, text: text, standalone: standalone }, function(res) { $("#results").text(res.html); $("#version").text(res.version);@@ -55,7 +59,7 @@ $("#to").change(newpage); }); </script>- <style type="text/css">+ <style> h1 { margin-bottom: 1em; } body { margin: auto; } textarea { height: auto; width: 100%; font-family: monospace; margin-top: 15px; }@@ -115,6 +119,10 @@ <option value="twiki">TWiki</option> <option value="vimwiki">Vimwiki</option> </select>+ <input type="checkbox" id="standalone" name="standalone">+ <label for="standalone">Generate standalone document+ <a href="https://pandoc.org/MANUAL.html#option--standalone" target="_blank">(?)</a>+ </label> <br/> <textarea id="text" maxlength="3000" rows="15"></textarea> </div>
trypandoc/trypandoc.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- | Module : Main- Copyright : © 2014-2019 John MacFarlane <jgm@berkeley.edu>+ Copyright : © 2014-2020 John MacFarlane <jgm@berkeley.edu> License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>@@ -41,6 +41,9 @@ text <- getParam "text" >>= checkLength . fromMaybe T.empty fromFormat <- fromMaybe "" <$> getParam "from" toFormat <- fromMaybe "" <$> getParam "to"+ standalone <- (==) "1" . fromMaybe "" <$> getParam "standalone"+ compiledTemplate <- runIO . compileDefaultTemplate $ toFormat+ let template = if standalone then either (const Nothing) Just compiledTemplate else Nothing let reader = case runPure $ getReader fromFormat of Right (TextReader r, es) -> r readerOpts{ readerExtensions = es }@@ -48,7 +51,7 @@ ++ T.unpack fromFormat let writer = case runPure $ getWriter toFormat of Right (TextWriter w, es) -> w writerOpts{- writerExtensions = es }+ writerExtensions = es, writerTemplate = template } _ -> error $ "could not find writer for " ++ T.unpack toFormat let result = case runPure $ reader (tabFilter 4 text) >>= writer of