srid/emanote

Obsidian-style callouts

srid opened this issue · 2 comments

srid commented

Spec: https://help.obsidian.md/Editing+and+formatting/Callouts

Discussion: #307

Progress

  • Basic callouts #466
  • [bug] Don't render footnotes inside of callout (they are already rendered in the page)
  • Support the rest of callout types
  • Nested callouts
  • Foldable callouts

Tangential

srid commented

One way to implement this (especially as Pandoc AST is not flexible enough) is by having heist-extra generate the same HTML div structure as Obsidian's publish:

https://github.com/srid/heist-extra/blob/54ff970f733dd45b5509d1c4c298927b6241041b/src/Heist/Extra/Splices/Pandoc/Render.hs#L67-L69

image image

And then style it in CSS separately.

srid commented

Actually we could just implement it as a PandocBlockRenderer (much like how embed wikilinks, queries, etc. are done)

queryResolvingSplice :: PandocBlockRenderer Model LMLRoute
queryResolvingSplice model _nr ctx noteRoute blk = do
B.CodeBlock
(_id', classes, _attrs)
(Q.parseQuery -> Just q) <-
pure blk
guard $ List.elem "query" classes
let mOtherCls = nonEmpty (List.delete "query" classes) <&> T.intercalate " " . toList
queryTpl = encodeUtf8 $ "/templates/filters/query-" <> fromMaybe "default" mOtherCls
pure $ do
tpl <- HE.lookupHtmlTemplateMust queryTpl
HE.runCustomTemplate tpl $ do
"query" ##
HI.textSplice (show q)
"result" ##
(HI.runChildrenWith . noteSpliceMap ($ ctx) model)
`foldMapM` Q.runQuery noteRoute model q