Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(website): Add MMark extension to render table with styles #100

Merged
merged 3 commits into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Neuron/Zettelkasten/Markdown.hs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE NoImplicitPrelude #-}

module Neuron.Zettelkasten.Markdown
( neuronMMarkExts,
)
where

import Neuron.Zettelkasten.Config (Config (..))
import Neuron.Zettelkasten.Markdown.Extension (setTableClass)
import Relude
import qualified Text.MMark as MMark
import qualified Text.MMark.Extension.Common as Ext
Expand All @@ -24,5 +25,6 @@ defaultExts =
Ext.kbd,
Ext.linkTarget,
Ext.punctuationPrettifier,
Ext.skylighting
Ext.skylighting,
setTableClass "ui celled table"
]
18 changes: 18 additions & 0 deletions src/Neuron/Zettelkasten/Markdown/Extension.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}

module Neuron.Zettelkasten.Markdown.Extension
( setTableClass,
)
where

import Lucid
import Relude
import Text.MMark.Extension (Block (Table), Extension)
import qualified Text.MMark.Extension as Ext

setTableClass :: Text -> Extension
setTableClass tableClass = Ext.blockRender $ \old block ->
case block of
table@(Table _ _) -> with (old table) [class_ tableClass]
other -> old other