2 title: ⌨️ MMark and Hakyll
6 I've moved over the blog to Hakyll, so things are a bit less makeshfit.
8 I really the syntax highlighting, but one problem I noticed was that the code blocks didn't show up on Safari Reader.
9 After doing a bit of digging it turned out that some time around Pandoc 2.0.4, skylighting
10 started adding line numbers that had an `<a>` tag, which seemed to throw Safari off.
13 <code class="sourceCode haskell">
14 <a class="sourceLine" id="cb1-1" data-line-number="1">
15 <span class="kw">data</span>
16 <span class="dt">RequestMessage</span> m req resp <span class="fu">=</span>
17 <span class="fu">...</span>
22 Unfortunately there doesn't seem to be a way to turn this off, and rather than try to strip off those tags myself,
23 I decided just to use another compiler other than Pandoc.
25 Since I was only going to be compiling markdown, I landed on [MMark](https://hackage.haskell.org/package/mmark).
26 Unlike other compilers, MMark is strict - I plugged it into hakyll:
29 mmarkCompiler :: Compiler (Item String)
31 fp <- getResourceFilePath
32 getResourceLBS >>= withItemBody (\lbs ->
33 let text = T.toStrict $ T.decodeUtf8 lbs
34 in case MMark.parse fp text of
35 Left e -> error (MMark.parseErrorsPretty text e)
36 Right doc -> return $ T.unpack $ Lucid.renderText $ MMark.render doc
39 And right off the bat it picked up a bunch of mistakes in my existing blog posts:
46 Checking for out-of-date items
48 updated templates/default.html
50 updated templates/post.html
51 updated posts/hakyll.md
52 updated posts/haskellMake.md
53 updated posts/hello.md
54 [ERROR] ./posts/lens.md:177:66:
56 177 | In `haskell-lsp` these are also generated via (Template Haskell)[https://artyom.me/lens-over-tea-6].
58 could not find a matching reference definition for "https://artyom.me/lens-over-tea-6"
61 It also comes with an extension for [ghc-syntax-highlighter](https://markkarpov.com/post/announcing-ghc-syntax-highlighter.html),
62 which was what I came for in the first place.
63 Setting it up was super easy:
66 MMark.render $ MMark.useExtensions extensions doc
67 where extensions = [ MMark.ghcSyntaxHighlighter
72 And now I have clean, Safari-readable tags:
75 <code class="sourceCode haskell">
76 <span class="kw">data</span>
77 <span class="dt">RequestMessage</span> m req resp <span class="fu">=</span>
78 <span class="fu">...</span>