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

Raw HTML support #191

Closed
wants to merge 4 commits into from
Closed
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- With this change, neuron can potentially support other text formats (org,
reST, etc.)
- Switch to GHC 8.6 (for reflex-dom)
- Raw HTML support (#191)

## 0.4.0.0

Expand Down
4 changes: 2 additions & 2 deletions dep/reflex-dom-pandoc/github.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"repo": "reflex-dom-pandoc",
"branch": "master",
"private": false,
"rev": "71ec620dcefdeef3aa2618a257b936fa5b27d65d",
"sha256": "1qwchjlv8r1kqcync3qba0f3admzbx99qfj6fhwn83xfk7mb9rwj"
"rev": "2fb4d7c9201d39c4a23e8e7067f36474674c22cd",
"sha256": "06l7a2rs7xi14d5nqz873pvl270vdhi863b7axxi6n6ybzzif2rr"
}
3 changes: 2 additions & 1 deletion src/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Neuron.Web.Generate (generateSite)
import Neuron.Web.Route (Route (..))
import Neuron.Web.View (renderRouteBody, renderRouteHead, style)
import Reflex.Dom.Core
import Reflex.Dom.Pandoc.Document (PandocBuilder)
import Relude
import qualified Rib

Expand All @@ -35,7 +36,7 @@ generateMainSite = do
Rib.writeRoute r $ decodeUtf8 @Text html
void $ generateSite config writeHtmlRoute

renderPage :: DomBuilder t m => Config -> Route g a -> (g, a) -> m ()
renderPage :: PandocBuilder t m => Config -> Route g a -> (g, a) -> m ()
renderPage config r val = elAttr "html" ("lang" =: "en") $ do
el "head" $ do
renderRouteHead config r val
Expand Down
5 changes: 3 additions & 2 deletions src/app/Neuron/Web/View.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import Neuron.Zettelkasten.ID (ZettelID (..), zettelIDSourceFileName, zettelIDTe
import Neuron.Zettelkasten.Zettel
import qualified Neuron.Zettelkasten.Zettel.View as ZettelView
import Reflex.Dom.Core
import Reflex.Dom.Pandoc.Document (PandocBuilder)
import Relude
import qualified Rib
import Rib.Extra.OpenGraph
Expand Down Expand Up @@ -121,7 +122,7 @@ renderOpenGraph OpenGraph {..} = do
then f $ URI.render uri'
else error $ description <> " must be absolute. this URI is not: " <> URI.render uri'

renderRouteBody :: DomBuilder t m => Config -> Route graph a -> (graph, a) -> m ()
renderRouteBody :: PandocBuilder t m => Config -> Route graph a -> (graph, a) -> m ()
renderRouteBody config r (g, x) = do
case r of
Route_ZIndex ->
Expand Down Expand Up @@ -181,7 +182,7 @@ renderSearch graph = do
el "script" $ text $ "let index = " <> toText (Aeson.encodeToLazyText index) <> ";"
el "script" $ text searchScript

renderZettel :: DomBuilder t m => Config -> (ZettelGraph, Zettel) -> m ()
renderZettel :: PandocBuilder t m => Config -> (ZettelGraph, Zettel) -> m ()
renderZettel config (graph, z@Zettel {..}) = do
divClass "zettel-view" $ do
ZettelView.renderZettelContent z
Expand Down
1 change: 1 addition & 0 deletions src/lib/Neuron/Markdown.hs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ neuronSpec =
CE.mathSpec,
CE.smartPunctuationSpec,
CE.attributesSpec,
CE.rawAttributeSpec,
CM.defaultSyntaxSpec {CM.syntaxBlockSpecs = defaultBlockSpecsSansRawHtml}
]
where
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Neuron/Zettelkasten/Query/View.hs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ buildQueryView = \case
-- TODO: not using Rib for ghcjs, but factorize this
zettelUrl :: ZettelID -> Text
zettelUrl zid =
"/" <> zettelIDText zid <> ".html"
zettelIDText zid <> ".html"

tagUrl :: Tag -> Text
tagUrl (Tag s) =
Expand Down
4 changes: 2 additions & 2 deletions src/lib/Neuron/Zettelkasten/Zettel/View.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ import Reflex.Dom.Core
import Reflex.Dom.Pandoc.Document
import Relude

renderZettelContent :: DomBuilder t m => Zettel -> m ()
renderZettelContent :: PandocBuilder t m => Zettel -> m ()
renderZettelContent Zettel {..} = do
divClass "ui raised segment zettel-content" $ do
elClass "h1" "header" $ text zettelTitle
elPandocDoc zettelContent
elPandoc zettelContent
renderTags zettelTags
whenJust zettelDay $ \day ->
elAttr "div" ("class" =: "date" <> "title" =: "Zettel creation date") $ text $ show day
Expand Down