first commit
This commit is contained in:
commit
68f8216b55
6
.ghc.environment.aarch64-darwin-9.4.8
Normal file
6
.ghc.environment.aarch64-darwin-9.4.8
Normal file
@ -0,0 +1,6 @@
|
||||
clear-package-db
|
||||
global-package-db
|
||||
package-db /Users/congyu/.cabal/store/ghc-9.4.8/package.db
|
||||
package-id base-4.17.2.1
|
||||
package-id pndc-typs-1.23.1-53806a08
|
||||
package-id text-2.0.2
|
16
filter.hs
Executable file
16
filter.hs
Executable file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env runhaskell
|
||||
-- filter.hs
|
||||
import Text.Pandoc.JSON
|
||||
import qualified Data.Text.IO as TIO
|
||||
import qualified Data.Text as T
|
||||
|
||||
doInclude :: Block -> IO Block
|
||||
doInclude cb@(CodeBlock (id, classes, namevals) contents) =
|
||||
case lookup (T.pack "include") namevals of
|
||||
Just f -> CodeBlock (id, classes, namevals) <$>
|
||||
TIO.readFile (T.unpack f)
|
||||
Nothing -> return cb
|
||||
doInclude x = return x
|
||||
|
||||
main :: IO ()
|
||||
main = toJSONFilter doInclude
|
5
input.md
Normal file
5
input.md
Normal file
@ -0,0 +1,5 @@
|
||||
Here's the pandoc README:
|
||||
|
||||
~~~~ {include="input.md"}
|
||||
this will be replaced by contents of README
|
||||
~~~~
|
8
makefile
Normal file
8
makefile
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
.PHONY: filter showAST
|
||||
|
||||
filter:
|
||||
pandoc -fmarkdown -thtml input.md --filter ./filter.hs > output.html
|
||||
|
||||
showAST:
|
||||
pandoc -fmarkdown -tnative input.md
|
6
output.html
Normal file
6
output.html
Normal file
@ -0,0 +1,6 @@
|
||||
<p>Here’s the pandoc README:</p>
|
||||
<pre data-include="input.md"><code>Here's the pandoc README:
|
||||
|
||||
~~~~ {include="input.md"}
|
||||
this will be replaced by contents of README
|
||||
~~~~</code></pre>
|
Loading…
x
Reference in New Issue
Block a user