1
1
mirror of https://github.com/aelve/guide.git synced 2024-12-24 21:35:06 +03:00

Move blazeToHtml into another package

This commit is contained in:
Artyom 2016-03-15 14:20:06 +03:00
parent 993e33d154
commit 6c94fc5231
2 changed files with 5 additions and 12 deletions

View File

@ -39,9 +39,9 @@ executable guide
, acid-state == 0.14.*
, base >=4.8 && <4.9
, base-prelude
, blaze-html >= 0.8.1.1
, cheapskate
, cheapskate-highlight == 0.1.*
, cheapskate-lucid == 0.1.*
, containers >= 0.5
, ekg
, ekg-core

View File

@ -23,20 +23,15 @@ import Data.Text (Text)
import Text.Megaparsec
-- HTML
import Lucid
import qualified Text.Blaze.Html.Renderer.Text as Blaze
import qualified Text.Blaze.Html as Blaze
-- Seq (used by Cheapskate)
-- Sequence (used by Cheapskate)
import Data.Sequence
-- Markdown
import Cheapskate
import Cheapskate.Html
import Cheapskate.Lucid
import Cheapskate.Highlight
import ShortcutLinks
blazeToLucid :: Monad m => Blaze.Html -> HtmlT m ()
blazeToLucid = toHtmlRaw . Blaze.renderHtml
-- | Convert a Markdown structure to a string with formatting removed.
stringify :: Inline -> Text
stringify = execWriter . walkM go
@ -102,7 +97,7 @@ renderMarkdownLine :: Monad m => Text -> HtmlT m ()
renderMarkdownLine s = do
let Doc opts blocks = markdown def{allowRawHtml=False} s
inlines = extractInlines =<< blocks
blazeToLucid (renderInlines opts (walk shortcutLinks inlines))
renderInlines opts (walk shortcutLinks inlines)
where
extractInlines (Para xs) = xs
extractInlines (Header _ xs) = xs
@ -115,6 +110,4 @@ renderMarkdownLine s = do
-- TODO: rename to renderMarkdownBlocks
renderMarkdownBlock :: Monad m => Text -> HtmlT m ()
renderMarkdownBlock =
blazeToLucid . renderDoc .
highlightDoc . walk shortcutLinks .
markdown def
renderDoc . highlightDoc . walk shortcutLinks . markdown def