readableFilter/output.html
2025-04-22 21:32:10 +08:00

36 lines
1.2 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>Heres the pandoc README:</p>
<div class="sourceCode" id="cb1" data-include="filter.hs"><pre
class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="dt">Foo</span><span class="ot">::</span> <span class="dt">Div</span> <span class="ot">-&gt;</span> <span class="dt">Div</span></span></code></pre></div>
<div data-include="filter.hs">
#!/usr/bin/env runhaskell
-- filter.hs
import Text.Pandoc.JSON
import qualified Data.Text.IO as TIO
import qualified Data.Text as T
file2Block :: FilePath -&gt; IO [Block]
file2Block f = do
contents &lt;- TIO.readFile f
return [Plain [Str contents]]
doInclude :: Block -&gt; IO Block
doInclude cb@(Div (id, classes, namevals) contents) =
case lookup (T.pack "include") namevals of
Just f -&gt; Div (id, classes, namevals) &lt;$&gt;
file2Block (T.unpack f)
Nothing -&gt; return cb
doInclude x = return x
main :: IO ()
main = toJSONFilter doInclude
</div>
<div class="Theorem">
<p>test thm1</p>
</div>
<div id="thm2" class="Theorem">
<p>test thm2</p>
</div>
<div id="thm3" class="Theorem">
<p>test thm3</p>
</div>