diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2013-04-02 21:08:38 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2013-04-14 00:31:39 -0500 |
commit | 4fa2a947590f78160dac3197672e475f433f0e4f (patch) | |
tree | 658c4e6ec08ce1cf3dc4217d61dd1fb6c75cb656 /src/Text/Pandoc.hs | |
parent | dede39452f9488002daa1b402eed8d25aa88994f (diff) | |
download | pandoc-4fa2a947590f78160dac3197672e475f433f0e4f.tar.gz |
Added `Text.Pandoc.Writers.Custom`, `--print-custom-lua-writer`.
pandoc -t data/sample.lua
will load the script sample.lua and use it as a custom writer.
data/sample.lua is provided as an example.
Added `--print-custom-lua-writer` option to print the sample
script.
Diffstat (limited to 'src/Text/Pandoc.hs')
-rw-r--r-- | src/Text/Pandoc.hs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/Text/Pandoc.hs b/src/Text/Pandoc.hs index cd2aa0fd3..0d1d6375e 100644 --- a/src/Text/Pandoc.hs +++ b/src/Text/Pandoc.hs @@ -99,6 +99,7 @@ module Text.Pandoc , writeFB2 , writeOrg , writeAsciiDoc + , writeCustom -- * Rendering templates and default templates , module Text.Pandoc.Templates -- * Version @@ -142,11 +143,12 @@ import Text.Pandoc.Writers.MediaWiki import Text.Pandoc.Writers.Textile import Text.Pandoc.Writers.Org import Text.Pandoc.Writers.AsciiDoc +import Text.Pandoc.Writers.Custom import Text.Pandoc.Templates import Text.Pandoc.Options import Text.Pandoc.Shared (safeRead, warn) import Data.ByteString.Lazy (ByteString) -import Data.List (intercalate) +import Data.List (intercalate, isSuffixOf) import Data.Version (showVersion) import Text.JSON.Generic import Data.Set (Set) @@ -286,7 +288,10 @@ getWriter s = Left e -> Left $ intercalate "\n" $ [m | Message m <- errorMessages e] Right (writerName, setExts) -> case lookup writerName writers of - Nothing -> Left $ "Unknown writer: " ++ writerName + Nothing + | ".lua" `isSuffixOf` s -> + Right $ IOStringWriter $ writeCustom s + | otherwise -> Left $ "Unknown writer: " ++ writerName Just (PureStringWriter r) -> Right $ PureStringWriter $ \o -> r o{ writerExtensions = setExts $ getDefaultExtensions writerName } |