mmark-ext-0.2.1.5: Commonly useful extensions for the MMark markdown processor
Copyright© 2017–present Mark Karpov
LicenseBSD 3 clause
MaintainerMark Karpov <markkarpov92@gmail.com>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Text.MMark.Extension.Common

Description

Commonly useful extensions for the MMark markdown processor.

We suggest using a qualified import, like this:

import qualified Text.MMark.Extension.Common as Ext

Here is an example that uses several extensions from this module at the same time, it should give you an idea where to start:

{-# LANGUAGE OverloadedStrings #-}

module Main (main) where

import qualified Data.Text.IO                as T
import qualified Data.Text.Lazy.IO           as TL
import qualified Lucid                       as L
import qualified Text.MMark                  as MMark
import qualified Text.MMark.Extension.Common as Ext
import qualified Text.Megaparsec             as M

main :: IO ()
main = do
  let input = "input.md"
  txt <- T.readFile input
  case MMark.parse input txt of
    Left bundle -> putStrLn (M.errorBundlePretty bundle)
    Right r ->
      let toc = MMark.runScanner r (Ext.tocScanner (> 1))
      in TL.writeFile "output.html"
          . L.renderText
          . MMark.render
          . MMark.useExtensions
              [ Ext.toc "toc" toc
              , Ext.punctuationPrettifier
              , Ext.skylighting ]
          $ r

Documentation