Shake.hs, tools/pandoc-demote-headers: switch to lua script filter

This commit is contained in:
Everett Hildenbrandt 2018-04-17 20:25:06 -06:00 committed by Simon Michael
parent a4d30512bd
commit 33e08a7d86
3 changed files with 7 additions and 18 deletions

View File

@ -82,8 +82,8 @@ main = do
-- <$> S.getDirectoryContents "tools"
let pandocFilters =
[
"tools" </> "pandoc-demote-headers"
,"tools" </> "pandoc-drop-html-blocks"
--- "tools" </> "pandoc-demote-headers"
"tools" </> "pandoc-drop-html-blocks"
,"tools" </> "pandoc-drop-html-inlines"
,"tools" </> "pandoc-drop-links"
,"tools" </> "pandoc-drop-notes"
@ -273,7 +273,7 @@ main = do
cmd Shell
"m4 -P -DMAN -DWEB -I" dir lib src "|"
pandoc "-f markdown -t markdown-fenced_divs --atx-headers"
"--filter tools/pandoc-demote-headers"
"--lua-filter tools/pandoc-demote-headers.lua"
-- "--filter tools/pandoc-add-toc"
-- "--filter tools/pandoc-drop-man-blocks"
">>" out
@ -290,7 +290,7 @@ main = do
-- "--filter tools/pandoc-drop-man-blocks"
"--filter tools/pandoc-drop-toc"
-- "--filter tools/pandoc-capitalize-headers"
"--filter tools/pandoc-demote-headers"
"--lua-filter tools/pandoc-demote-headers.lua"
">>" webmanall :: Action ExitCode
-- adjust and combine recipe mds for single-page web output, using pandoc

View File

@ -1,14 +0,0 @@
#!/usr/bin/env stack
{- stack runghc --verbosity info --package pandoc-types -}
import Text.Pandoc.JSON
import Text.Pandoc.Walk
import Data.Char (toUpper)
main :: IO ()
main = toJSONFilter demoteHeaders
demoteHeaders :: Block -> Block
demoteHeaders (Header l attr xs) = Header (l+1) attr xs
demoteHeaders x = x

View File

@ -0,0 +1,3 @@
function Header(h)
return pandoc.Header(h.level + 1, h.content, h.attrs)
end