2

I wanted to enable the Ext_autolink_bare_uris pandoc extension for Hakyll posts. I followed the instructions given here, and everything seems to be working... except that extension! The bare URI's in posts are not transformed into a link. Everything else seems to function as normal. Here's the code in site.hs:

import qualified Data.Set as S
import           Text.Pandoc.Options

...

customPandocCompiler :: Compiler (Item String)
customPandocCompiler =
  let customExtensions = [Ext_autolink_bare_uris]
      defaultExtensions = writerExtensions defaultHakyllWriterOptions
      newExtensions = foldr S.insert defaultExtensions customExtensions
      writerOptions = defaultHakyllWriterOptions {
                        writerExtensions = newExtensions
                      }
  in pandocCompilerWith defaultHakyllReaderOptions writerOptions

The customPandocCompiler is used in all the relevant places. The code compiles normally, but does not yield the desired effect. Can anyone help me discover why?

Thank you in advance.

wmnorth
  • 247
  • 4
  • 9
  • what input/output are you expecting? about bare_uris extension: `Makes all absolute URIs into links, even when not surrounded by pointy braces` (from the MANUAL) – mb21 Aug 28 '17 at 07:45
  • Well, the input is an absolute URL in a markdown file, and the output I expected was that absolute URL, but clickable, in the HTML output. Instead what I get is the URL enclosed in `

    ` tags.
    – wmnorth Aug 28 '17 at 08:55

1 Answers1

0

Question is a bit old now, but maybe this will help someone.

Newer Hakyll releases use Pandoc 2.x which changed a lot of things (see PR #557 especially). Notably the Set model for extensions is gone, in favour of custom types.

Anyway, here's a fairly customised setup that works well for us - disabling one default reader extension, and adding a few extra ones. There's probably a neater way of doing this still.

customRenderPandoc :: Item String -> Compiler (Item String)
customRenderPandoc = renderPandocWith customReaderOptions defaultHakyllWriterOptions
    where customReaderOptions = def { readerExtensions = extraReaderExts <> customReaderExts }
          extraReaderExts = extensionsFromList [Ext_auto_identifiers, Ext_ascii_identifiers, Ext_emoji, Ext_backtick_code_blocks]
          customReaderExts = disableExtension Ext_implicit_figures $ pandocExtensions

Note also I found it's not always obvious (nor typesafe) which extensions are reader and which writer. I guess some can be both... but check you've put yours in the right place as it's an easy mistake.

declension
  • 4,110
  • 22
  • 25