Package

purescript-markdown-smolder

Repository
hgiasac/purescript-markdown-smolder
License
Apache-2.0
Uploaded by
hgiasac
Published on
2018-11-11T08:41:06Z

Pursuit ComVer Build Status

This library is forked from original one, with up-to-date dependencies and breaking changes fixed. I also add simple customized options:

  • HTML class for markups ul, ol, p, h1, h2,...
  • Customized code block renderer

Installation

bower install purescript-slamdown-smolder

Example

compileMd' :: forall e. ToMarkupOptions e -> String -> String 
compileMd' options input =
  either identity (toMarkup' options >>> render)
  (parseMd input :: Either String (SlamDownP String))

compileMd :: String -> String
compileMd = compileMd' defaultToMarkupOptions

compileMd "# Hello"
-- <h1 id=\"Hello\">Hello</h1>

compileMd' (defaultToMarkupOptions { hideHeadingId = true }) "# Hello"
-- <h1>Hello</h1>

Quick Reference

Module Text.Markdown.SlamDown.Smolder

ToMarkupOptions

type ToMarkupOptions e = 
  { hideHeadingId :: Boolean
  , hClasses :: Array (Tuple Int String)
  , olClass :: String
  , ulClass :: String
  , pClass :: String
  , renderFencedCodeBlock :: String -> List String -> Markup e 
  }

Convert options, you can set classes into common markups If you don't want to set id in headings, set hideHeadingId If you need to render code block content to another markup templates, define function renderFencedCodeBlock option

defaultToMarkupOptions

Default convert options

defaultToMarkupOptions :: forall e. ToMarkupOptions e

toMarkup

toMarkup :: forall a e. SlamDownP a -> Markup e

Render purescript-markdown to purescript-smolder, with default options.

toMarkup'

toMarkup' :: forall a e. ToMarkupOptions e -> SlamDownP a -> Markup e

Convert Smolder markup from Slamdown Markdown with options