Skip to content
Open
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
2 changes: 2 additions & 0 deletions emanote/src/Emanote.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import Emanote.View.Tailwind (compileTailwindCss, generatedCssFile)
import Emanote.View.Template qualified as View
import Optics.Core ((.~), (^.))
import Relude
import Skylighting (defaultSyntaxMap)
import System.FilePath ((</>))
import UnliftIO.Async (race_)

Expand Down Expand Up @@ -73,6 +74,7 @@ defaultEmanoteConfig cli =
, _emanoteConfigNoteFn = id
, _emanoteConfigPandocRenderers = defaultEmanotePandocRenderers
, _emanoteCompileTailwind = False
, _emanoteSyntaxMap = defaultSyntaxMap
}

run :: EmanoteConfig -> IO ()
Expand Down
7 changes: 5 additions & 2 deletions emanote/src/Emanote/Model/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import Optics.Core (Prism')
import Optics.Operators ((%~), (.~), (^.))
import Optics.TH (makeLenses)
import Relude
import Skylighting.Types (SyntaxMap)
import Text.Pandoc.Scripting (ScriptingEngine)

data Status = Status_Loading | Status_Ready
Expand All @@ -56,6 +57,7 @@ data ModelT encF = Model
, _modelEmaCLIAction :: Ema.CLI.Action
, _modelRoutePrism :: encF (Prism' FilePath SiteRoute)
, _modelPandocRenderers :: EmanotePandocRenderers Model LMLRoute
, _modelSyntaxMap :: SyntaxMap
-- ^ Dictates how exactly to render `Pandoc` to Heist nodes.
, _modelScriptingEngine :: ScriptingEngine
, _modelCompileTailwind :: Bool
Expand Down Expand Up @@ -120,8 +122,8 @@ modelPluginBaseDir :: ModelT f -> [FilePath]
modelPluginBaseDir m =
fst . locPath <$> Set.toAscList (m ^. modelLayers)

emptyModel :: Set Loc -> Ema.CLI.Action -> EmanotePandocRenderers Model LMLRoute -> ScriptingEngine -> Bool -> Bool -> UUID -> Stork.IndexVar -> ModelEma
emptyModel layers act ren scriptingEngine ctw allowBrokenLua instanceId storkVar =
emptyModel :: Set Loc -> Ema.CLI.Action -> EmanotePandocRenderers Model LMLRoute -> ScriptingEngine -> Bool -> Bool -> SyntaxMap -> UUID -> Stork.IndexVar -> ModelEma
emptyModel layers act ren scriptingEngine ctw allowBrokenLua syntaxMap instanceId storkVar =
Model
{ _modelStatus = Status_Loading
, _modelLayers = layers
Expand All @@ -130,6 +132,7 @@ emptyModel layers act ren scriptingEngine ctw allowBrokenLua instanceId storkVar
, _modelPandocRenderers = ren
, _modelScriptingEngine = scriptingEngine
, _modelCompileTailwind = ctw
, _modelSyntaxMap = syntaxMap
, _modelAllowBrokenLuaFilters = allowBrokenLua
, _modelInstanceID = instanceId
, -- Inject a placeholder `index.md` to account for the use case of emanote
Expand Down
5 changes: 4 additions & 1 deletion emanote/src/Emanote/Pandoc/Renderer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import Heist.Extra.Splices.Pandoc qualified as Splices
import Heist.Extra.Splices.Pandoc.Ctx qualified as Splices
import Heist.Interpreted qualified as HI
import Relude
import Skylighting.Types (SyntaxMap)
import Text.Pandoc.Definition qualified as B

-- | Custom Heist renderer function for specific Pandoc AST nodes.
Expand All @@ -48,14 +49,16 @@ mkRenderCtxWithPandocRenderers ::
(Monad m) =>
PandocRenderers model route ->
Map Text Text ->
SyntaxMap ->
model ->
route ->
-- | Rendering feature selection (code highlighting, static math, …)
Splices.RenderFeatures ->
HeistT Identity m Splices.RenderCtx
mkRenderCtxWithPandocRenderers nr classRules model x =
mkRenderCtxWithPandocRenderers nr classRules syntaxMap model x =
Splices.mkRenderCtx
classRules
syntaxMap
(\ctx -> dispatchBlock model nr ctx x)
(\ctx -> dispatchInline model nr ctx x)

Expand Down
4 changes: 4 additions & 0 deletions emanote/src/Emanote/Source/Dynamic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Emanote.Source.Dynamic (
emanoteSiteInput,
EmanoteConfig (..),
emanoteCompileTailwind,
emanoteSyntaxMap,
emanoteConfigCli,
emanoteConfigNoteFn,
emanoteConfigPandocRenderers,
Expand All @@ -31,6 +32,7 @@ import Emanote.Source.Pattern qualified as Pattern
import Optics.TH (makeLenses)
import Paths_emanote qualified
import Relude
import Skylighting.Types (SyntaxMap)
import System.UnionMount qualified as UM
import Text.Pandoc.Lua (getEngine)
import UnliftIO (MonadUnliftIO)
Expand All @@ -45,6 +47,7 @@ data EmanoteConfig = EmanoteConfig
-- ^ How to render Pandoc to Heist HTML.
, _emanoteCompileTailwind :: Bool
-- ^ Whether to replace Tailwind2 CDN with a minimized Tailwind3 CSS file.
, _emanoteSyntaxMap :: SyntaxMap
}

{- | Make an Ema `Dynamic` for the Emanote model. The bulk of logic
Expand All @@ -70,6 +73,7 @@ emanoteSiteInput cliAct EmanoteConfig {..} = do
scriptingEngine
_emanoteCompileTailwind
(CLI.allowBrokenLuaFilters _emanoteConfigCli)
_emanoteSyntaxMap
instanceId
storkIndex
-- NOTE: Per-layer ignore patterns are loaded once at startup. Edits
Expand Down
1 change: 1 addition & 0 deletions emanote/src/Emanote/View/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ mkTemplateRenderCtx model r meta =
Renderer.mkRenderCtxWithPandocRenderers
pandocRenderers
classRules
(model ^. M.modelSyntaxMap)
model
r
renderFeatures
Expand Down
Loading