diff options
author | ache <ache@ache.one> | 2017-08-17 05:17:10 +0200 |
---|---|---|
committer | ache <ache@ache.one> | 2017-08-17 05:17:10 +0200 |
commit | 4d483292bab90796fac57ff1bbdd025219b1c852 (patch) | |
tree | 3e40db773c2f876f30e3365c12e98af12cf35014 /src/articleFilter.hs | |
parent | Ajout des liens sur les logos SVG (diff) |
New website prototype
Diffstat (limited to 'src/articleFilter.hs')
-rw-r--r-- | src/articleFilter.hs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/articleFilter.hs b/src/articleFilter.hs new file mode 100644 index 0000000..a94cd3d --- /dev/null +++ b/src/articleFilter.hs @@ -0,0 +1,55 @@ +import Text.Pandoc +import Text.Pandoc.JSON +import Control.Monad.State +import Id + + +{- + - Écrit par Hédy GIRAUDEAU + - 27/07/17 +-} +extractStart :: [Inline] -> ([Inline],[Inline]) +extractStart [] = ([],[]) +extractStart ((SoftBreak):q) = ((SoftBreak):y, z) where (y,z) = (extractStart q) +extractStart ((LineBreak):q) = ((LineBreak):y, z) where (y,z) = (extractStart q) +extractStart (img@(Image _ _ _):q) = (img: y, z) where (y,z) = (extractStart q) +extractStart x = ([],x) + + + + +transformBlock cnt ( hdF@(Header 1 _ inlines) : paraF@(Para inlinesP) : blocks ) = + return (( (RawBlock (Format "html") + ( start_header ) + ) : hdF : + (RawBlock (Format "html") + ( end_header ) + ) : (Plain inlinesP) : + (RawBlock (Format "html") + ( end_intro ) + ) : blocks + ) ++ [ (RawBlock (Format "html") + (end_article) ) + ]) + where start_header = "<header>" + end_header = "</header><section class=\"entry-content clearfix\" >" + end_intro = "" + end_article = "</section>" + +--transformBlock _ ((Para inlines):tl) = +-- return ((Plain plainInline):(Para paraInline:tl)) +-- where (plainInline, paraInline) = extractStart(inlines) + + +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: |