Thin PureScript FFI binding for markdown-it. Parses CommonMark (+ collapsible plugin) and exposes the token stream as a PureScript record type. No rendering opinion — consumers walk the tokens however they want.
# PureScript dependency
spago install markdown-it-js
# npm dependency (required — provides the JS runtime)
bun add markdown-it markdown-it-collapsibleimport MarkdownIt (MdToken(..), parse)
tokens :: Array MdToken
tokens = parse "# Hello **world**"parse returns a flat array of tokens with open/close pairs. Inline content (text, bold, links, etc.) lives in the children array of inline tokens.
type MdAttr = { key :: String, value :: String }
newtype MdToken = MdToken
{ type :: String -- "paragraph_open", "inline", "fence", etc.
, tag :: String -- "p", "h1", "code", "a", etc.
, nesting :: Int -- 1 (open), 0 (self-close), -1 (close)
, content :: String -- text content (inline/text/code/fence tokens)
, children :: Array MdToken -- child tokens (non-empty for type="inline")
, markup :: String -- delimiter, e.g. "**", "```", "+++"
, info :: String -- fence info string, e.g. "js"
, attrs :: Array MdAttr -- HTML attributes, e.g. {key:"href", value:"url"}
, hidden :: Boolean -- true on tight list paragraphs
}bun install
spago build
spago testApache-2.0