From 6f5a6cd7353b8ff8243c86df75432780ba643944 Mon Sep 17 00:00:00 2001 From: ache Date: Tue, 6 Feb 2018 05:33:32 +0100 Subject: no pandoc dependencies --- src/Id.hs | 19 ------------------ src/Secret.hs | 46 ------------------------------------------- src/articleFilter.hs | 55 ---------------------------------------------------- src/introFilter.hs | 51 ------------------------------------------------ src/titleFilter.hs | 36 ---------------------------------- 5 files changed, 207 deletions(-) delete mode 100644 src/Id.hs delete mode 100644 src/Secret.hs delete mode 100644 src/articleFilter.hs delete mode 100644 src/introFilter.hs delete mode 100644 src/titleFilter.hs (limited to 'src') diff --git a/src/Id.hs b/src/Id.hs deleted file mode 100644 index adc7e2e..0000000 --- a/src/Id.hs +++ /dev/null @@ -1,19 +0,0 @@ -module Id -( newId, - nextId -) where - -{- - - - - Écrit par Hédy GIRAUDEAU - - 27/07/17 - - --} - -import Data.IORef -import Data.Functor - -type Id_number a = IORef a - -newId = (newIORef 0) -nextId cnt = modifyIORef cnt (+1) >> (+0) <$> readIORef cnt diff --git a/src/Secret.hs b/src/Secret.hs deleted file mode 100644 index 7b428ce..0000000 --- a/src/Secret.hs +++ /dev/null @@ -1,46 +0,0 @@ -module Secret -( to_secret -) where - - -{- - - - - Écrit par Hédy GIRAUDEAU - - 27/07/17 - - --} - - - -import Text.Pandoc -import Text.Pandoc.JSON - - -firstLine :: [Inline] -> ([Inline],[Inline]) -firstLine [] = ([],[]) -firstLine ((SoftBreak) : x) = ([], x) -firstLine (x:q) = ([x] ++ y, z) where (y,z) = (firstLine q) - - - - -to_secret (BlockQuote (Para (Str(first) : inlines) : blocks)) = - Div - ("", ["secret"], []) - ([ - RawBlock (Format "html") - (start_detail ++ start_summary) - ] ++ [Plain $ fLine] ++ [ - RawBlock (Format "html") - (end_summary) - ] ++ [ Plain rest ]++ blocks ++ [ - RawBlock (Format "html") - (end_detail) - ] - ) - where start_detail = "
" - start_summary = "" - end_detail = "
" - end_summary = "" - (fLine, rest) = firstLine inlines - diff --git a/src/articleFilter.hs b/src/articleFilter.hs deleted file mode 100644 index a94cd3d..0000000 --- a/src/articleFilter.hs +++ /dev/null @@ -1,55 +0,0 @@ -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 = "
" - end_header = "
" - end_intro = "" - end_article = "
" - ---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: diff --git a/src/introFilter.hs b/src/introFilter.hs deleted file mode 100644 index 93603c0..0000000 --- a/src/introFilter.hs +++ /dev/null @@ -1,51 +0,0 @@ -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 = "
" - end_header = "
" - end_intro = "" - end_article = "
" - - - -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: diff --git a/src/titleFilter.hs b/src/titleFilter.hs deleted file mode 100644 index c215253..0000000 --- a/src/titleFilter.hs +++ /dev/null @@ -1,36 +0,0 @@ -import Text.Pandoc -import Text.Pandoc.JSON - -{- - - Écrit par Hédy GIRAUDEAU - - 27/07/17 --} - - -{- Convertit une liste de Inline (sorte de span, contie du formatage légé de - - texte) vers une chaine de caractère normal -} - -toString :: [Inline] -> String -toString [] = "" -toString inls@((Str f):tl) = f ++ (toString tl) -toString inls@((Space):tl) = " " ++ (toString tl) -toString inls@((Emph inls2):tl) = (toString inls2) ++ (toString tl) -toString inls@((SmallCaps inls2):tl) = (toString inls2) ++ (toString tl) -toString inls@((Strong inls2):tl) = (toString inls2) ++ (toString tl) -toString (_:tl) = (toString tl) - - -transformBlock :: [Block] -> [Block] -transformBlock ( hdF@(Header 1 _ inlines) : _ ) = [(Plain [(Str (toString inlines))])] - -transformBlock x = x - - -bar :: Pandoc -> Pandoc -bar x = bottomUp transformBlock x - -main :: IO() -main = toJSONFilter bar - - --- vim:set et: -- cgit v1.2.3