From b2b24557ef782e97ebe7a526d0bff6015278fdc8 Mon Sep 17 00:00:00 2001 From: ache Date: Sun, 20 Aug 2017 19:31:43 +0200 Subject: Gestion du titre dynamique --- article/article.m4 | 2 +- contact/index.html | 69 ------------------------------------------------------ contact/index.md | 21 +++++++++++++++++ headers.m4 | 9 ++++--- makefile | 17 +++++++++++--- src/titleFilter.hs | 36 ++++++++++++++++++++++++++++ 6 files changed, 76 insertions(+), 78 deletions(-) delete mode 100644 contact/index.html create mode 100644 contact/index.md create mode 100644 src/titleFilter.hs diff --git a/article/article.m4 b/article/article.m4 index b0c6174..49816d2 100644 --- a/article/article.m4 +++ b/article/article.m4 @@ -1,7 +1,7 @@ -include(headers.htm) +include(HEADER_HEADER) diff --git a/contact/index.html b/contact/index.html deleted file mode 100644 index fdb44f3..0000000 --- a/contact/index.html +++ /dev/null @@ -1,69 +0,0 @@ - - DuckDuckGo, Google en mieux ? - -

Contact

-
Pour parler d'un projet, d'un article, de programmation, de Mathématiques. Si vous voulez me parlez d'un de vos projets (personel ou professionel). Discuter de tout et de rien. C'est bien ici !
Je ne répond pas aux questions techniques ; pour ça, il est préférable d'utiliser les forums. Je suis présent sur les forums de ZesteDeSavoir et d'OpenClassroom.
-

Par e-mail


La méthode la plus simple et la plus efficace. Je suis joingnable à l'adresse ci dessous. Je répond généralement dans la journée ou le lendemain.Image adresse email




À travers le web


Sur twitter pour des questions rapides @arobase_che. Vous pouvez également m'envoyer un MP sur ZdS ou OC. Je possède également un compte GitHub.
Je n'ai pas de compte Facebook ni Skype (en n'en n'aurait jamais).






-
- diff --git a/contact/index.md b/contact/index.md new file mode 100644 index 0000000..000fa6d --- /dev/null +++ b/contact/index.md @@ -0,0 +1,21 @@ + +# Contact + +Pour parler d'un projet, d'un article, de programmation, + de Mathématiques. Si vous voulez me parlez d'un de vos projets +(personel ou professionel). Discuter de tout et de rien. C'est bien ici ! + +Je ne répond pas aux questions techniques ; pour cela, je vous redirige vers le forum de [Zeste de Savoir](http://www.zestedesavoir.com) + +#### Par e-mail + +La méthode la plus simple et la plus efficace. + Je suis joingnable à l'adresse ci dessous. Je répond généralement dans +la journée ou le lendemain. ![Image adresse email](res/contact.png) + +### À travers le web + +Sur twitter pour des questions rapides [\@arobase\_che](https://twitter.com/arobase_che). Vous pouvez également m'envoyer un MP sur [ZdS](http://zestedesavoir.com/membres/voiche/). +Je n'ai pas de compte Facebook (en n'en n'aurait jamais). + + diff --git a/headers.m4 b/headers.m4 index 7b4232a..210e300 100644 --- a/headers.m4 +++ b/headers.m4 @@ -1,10 +1,9 @@ - DuckDuckGo, Google en mieux ? + TITLE_TITLE - - - - + + + diff --git a/makefile b/makefile index 49043e2..ee646c2 100644 --- a/makefile +++ b/makefile @@ -4,7 +4,14 @@ ALL_ARTICLES_OUT=$(ALL_ARTICLES:.md=.html) ALL_ARTICLES_INTRO_OUT=$(ALL_ARTICLES:.md=_intro.html) BASE_HTML=left.htm headers.htm articles.htm -all: $(ALL_ARTICLES_OUT) index.html bin/articleFilter bin/introFilter clean +all: $(ALL_ARTICLES_OUT) index.html contact/index.html bin/articleFilter bin/introFilter bin/titleFilter + + +bin/titleFilter : src/titleFilter.hs + mkdir -p bin + mkdir -p /tmp/titleFilter + ghc -dynamic $< -isrc -outputdir /tmp/titleFilter -o $@ + bin/articleFilter: src/articleFilter.hs src/Id.hs @@ -20,9 +27,13 @@ bin/introFilter: src/introFilter.hs src/Id.hs article/%.html: article/%.md bin/articleFilter $(BASE_HTML) pandoc --filter bin/articleFilter $< > ${@:.html=.htm} - m4 -D tmpFileNameArticle=${@:.html=.htm} -D linkFileNameArticle=${<:.md=.html} article/article.m4 > $@ + m4 -D TITLE_TITLE="`pandoc --filter bin/titleFilter $<`" headers.m4 > ${basename $@}_header.html + m4 -D tmpFileNameArticle=${@:.html=.htm} -D linkFileNameArticle=${<:.md=.html} -D HEADER_HEADER=${basename $@}_header.html article/article.m4 > $@ -NUMBERS = 1 2 3 4 +contact/index.html: contact/index.md + pandoc $< > ${@:.html=.htm} + m4 -D TITLE_TITLE="`pandoc --filter bin/titleFilter $<`" headers.m4 > ${basename $@}_header.html + m4 -D tmpFileNameArticle=${@:.html=.htm} -D linkFileNameArticle=${<:.md=.html} -D HEADER_HEADER=${basename $@}_header.html article/article.m4 > $@ article/%_intro.html: article/%.md bin/introFilter pandoc --filter bin/introFilter $< > ${@:.html=.htm} diff --git a/src/titleFilter.hs b/src/titleFilter.hs new file mode 100644 index 0000000..c215253 --- /dev/null +++ b/src/titleFilter.hs @@ -0,0 +1,36 @@ +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-54-g00ecf