[Newbie] Don't let pandoc mess around with your html files..

84 views
Skip to first unread message

Alfredo

unread,
Nov 9, 2011, 3:10:33 AM11/9/11
to hakyll
Hi guys,
I've got a simple question: I'm migrating a tiny personal website from
Clojure to Haskell using Hakyll, so I already have a bunch of static
html files. I've extracted the common part into a template, but now I
need, for every section to render some content from an html file. For
example:

home.html <---
about.html <--- They contains only the "body" part of the page, i.e.
some html content within serveral div.

When I try to compile and build the site, I suspect that pandoc mess
around with my files, because I lose all the class attribute of
my images, resulting in a non-well-formatted website. Just to be
clear:

//Before Rendering
<img class="instant itiltleft icolorFFFCE9 ishadow50 left" src="img/
alfredo.jpg" width="200px">

//After rendering
<div class="figure">
<img src="img/alfredo.jpg"></img><p class="caption"></p>
</div>

//Desider behaviour
<img class="instant itiltleft icolorFFFCE9 ishadow50 left" src="img/
alfredo.jpg" width="200px">

In a nutshell I want to say to Hakyll (or Pandoc, whatever) "Hey,
don't transform this page, put its content inside the template body
and stop!

My setup is very basic, according to the tutorial on the website (i.e.
brochure).

Thanks in advance for any kind of help.

Bye,
Alfredo

Jasper Van der Jeugt

unread,
Nov 9, 2011, 3:23:52 AM11/9/11
to hak...@googlegroups.com
Hello,

The issue here is that, when using the default `pageCompiler`, your
page passes through Pandoc. Pandoc unfortunately strips away this
information, giving you the "wrong" HTML.

The solution is not to use `pageCompiler`. The definition of
`pageCompiler` is, put simply, something like:

pageCompiler =
readPageCompiler >>>
addDefaultFields >>> -- Sets some things like $path$
arr applySelf >>> -- Used to fill in $var$s in the page
pageRenderPandoc

You can add your own version in your `site.hs` file:

myPageCompiler =
readPageCompiler >>>
addDefaultFields >>> -- Sets some things like $path$
arr applySelf >>> -- Used to fill in $var$s in the page

And using this instead of `pageCompiler` should solve the issue. If it
doesn't, or if there's anything that's not clear, do not hesitate to
send a mail.

Hope this helps,
Cheers,
Jasper

Alfredo

unread,
Nov 9, 2011, 4:16:00 AM11/9/11
to hakyll
Thanks Jasper,
it worked like a charm!
For future reference, I post the little tweaks to your solution that
made it working:

import Control.Arrow ((>>>), arr) --Needed for staticPageCompiler

import Hakyll

staticPageCompiler = readPageCompiler >>>
addDefaultFields >>>
arr applySelf -- Get rid of the last arrow


Thanks, and happy coding :)
Alfredo
Reply all
Reply to author
Forward
0 new messages