first commit

This commit is contained in:
Yu Cong 2025-04-20 19:38:11 +08:00
commit 68f8216b55
5 changed files with 41 additions and 0 deletions

View 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
View 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
View 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
View 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
View File

@ -0,0 +1,6 @@
<p>Heres the pandoc README:</p>
<pre data-include="input.md"><code>Here&#39;s the pandoc README:
~~~~ {include=&quot;input.md&quot;}
this will be replaced by contents of README
~~~~</code></pre>