Syntax highlighting works with pandoc, does not work in hakyll

222 views
Skip to first unread message

Tinky Holloway

unread,
Sep 27, 2016, 9:47:15 PM9/27/16
to hakyll
I am starting out with hakyll and am looking to have syntax highlighting in some posts.

I'm using the site.hs that is generated with hakyll-init. I've created a markdown syntax post that contains the lines:

``` haskell
main :: IO ()
main = putStrLn "Hello"
```


When I run this through pandoc I get:

<div class="sourceCode"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span class="ot">main ::</span> <span class="dt">IO</span> ()
main
<span class="fu">=</span> putStrLn <span class="st">&quot;Hello&quot;</span></code></pre></div>

When I look at the source generated by hakyll I only get:

<pre class="haskell"><code>main :: IO ()
main = putStrLn &quot;Hello&quot;
</code></pre>

Any ideas?

Sergey Bushnyak

unread,
Sep 28, 2016, 5:37:11 AM9/28/16
to hak...@googlegroups.com
You need to specify configuration 

```
myPandocCompiler =
  pandocCompilerWith
    defaultHakyllReaderOptions
    defaultHakyllWriterOptions
      { writerHtml5            = True
      , writerHighlight        = True
      , writerHighlightStyle   = pygments
      , writerHTMLMathMethod   = MathML Nothing                         
      , writerEmailObfuscation = NoObfuscation
      }
```
note highlight style parameter, and use it for conversion
```
-- Apply Pandoc compiler to convert articles from internal format
match (fromGlob (path ++ "/content/articles/*.md")) $ 
  version "convertedPage" $
    compile $ do
      myPandocCompiler >>= saveSnapshot "contentM"
```
Don't forget to add css generated by pandoc.

--
You received this message because you are subscribed to the Google Groups "hakyll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hakyll+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Take care,
Sergey Bushnyak
CTO, Kelecorix, LLC

Tinky Holloway

unread,
Sep 28, 2016, 11:46:53 PM9/28/16
to hakyll

You need to specify configuration 

Thank you Sergey.

I assume that `writerHighlightStyle` controls a tokenizer and the css file applies an actual styling of the tokens? With my little source code example I was unable too see any difference in output when I played around putting different styles in here.

Sergey Bushnyak

unread,
Sep 29, 2016, 10:19:58 AM9/29/16
to hak...@googlegroups.com
Yes, you need to attach proper css, pandoc can generate it for you. In other case it will be just proper html tags, but all the colors in css.

--
You received this message because you are subscribed to the Google Groups "hakyll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hakyll+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages