summaryrefslogtreecommitdiff
path: root/src/introFilter.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/introFilter.hs')
-rw-r--r--src/introFilter.hs51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/introFilter.hs b/src/introFilter.hs
new file mode 100644
index 0000000..93603c0
--- /dev/null
+++ b/src/introFilter.hs
@@ -0,0 +1,51 @@
+import Text.Pandoc
+import Text.Pandoc.JSON
+import Control.Monad.State
+import Id
+
+
+{-
+ - Écrit par Hédy GIRAUDEAU
+ - 27/07/17
+-}
+firstPara :: [Block] -> [Block]
+firstPara [] = []
+firstPara (p@(Para x):blocks) = [(Para x)]
+firstPara (x:blocks) = (firstPara blocks)
+
+setMignature (id, classes, mapsAttrib) = (id, "miniature":classes, mapsAttrib)
+
+
+purgePara (Para (Image x y (trgt,title):_)) = (Para [(Image (setMignature x) y ("article/" ++ trgt, title))])
+purgePara (Para (x:t)) = purgePara (Para t)
+purgePara (Para []) = (Para [])
+
+transformBlock cnt ( hdF@(Header 1 _ inlines) : paraF@(Para inlinesP) : blocks ) =
+ return (( (RawBlock (Format "html")
+ ( start_header )
+ ) : hdF :
+ (RawBlock (Format "html")
+ ( end_header )
+ ) : purgePara(paraF) : firstPara(blocks)
+ ) ++ [ (RawBlock (Format "html")
+ (end_article) )
+ ])
+ where start_header = "<header>"
+ end_header = "</header><section class=\"entry-content clearfix\" >"
+ end_intro = ""
+ end_article = "</section>"
+
+
+
+transformBlock _ x = return x
+
+
+bar :: Pandoc -> IO Pandoc
+bar x = do cnt <- newId
+ bottomUpM (transformBlock cnt) x
+
+main :: IO()
+main = toJSONFilter bar
+
+
+-- vim:set et: