mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-24 15:44:59 +08:00
Added a plugin system, based on hint.
+ In Text.Pandoc.Definition, added processIn, processInM, and queryIn, and deprecated processPandoc and queryPandoc for these more general functions, which are useful in writing plugins. + Added module Text.Pandoc.Plugins. + Added a --plugins option to Main, and code to run the parsed pandoc document through all the plugins. + Provided five sample plugin files in the plugins/ directory. + Documented --plugin in the pandoc man page and README. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1519 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
module IncludeFilePlugin (transform) where
|
||||
import Text.Pandoc
|
||||
import Text.Pandoc.Shared
|
||||
import Control.Monad
|
||||
|
||||
-- This plugin allows you to include the contents of an
|
||||
-- external file in a delimited code block like this:
|
||||
--
|
||||
-- ~~~ {include="filename"}
|
||||
-- ~~~
|
||||
--
|
||||
-- Trailing newlines are trimmed.
|
||||
|
||||
transform :: Block -> IO Block
|
||||
transform cb@(CodeBlock (id, classes, namevals) contents) =
|
||||
case lookup "include" namevals of
|
||||
Just f -> return . (CodeBlock (id, classes, namevals) . stripTrailingNewlines) =<< readFile f
|
||||
Nothing -> return cb
|
||||
transform x = return x
|
||||
Reference in New Issue
Block a user