Describe the bug
Headings have an id attribute when the source is markdown, e.g.: https://emanote.srid.ca/guide/lua-filters#demo
When the source is org, that does not work: e.g.: https://emanote.srid.ca/guide/orgmode#syntax
Details
Looking at pandoc native format, these two documents are identical:
[ Header 1 ( "hello" , [] , [] ) [ Str "Hello" ]
, Header 2 ( "world" , [] , [] ) [ Str "World" ]
]
Somehow they are not rendered the same in emanote. Should these two methods be merged together?
|
parseNoteOrg :: (MonadWriter [Text] m) => Text -> m (Pandoc, Aeson.Value) |
|
parseNoteOrg s = |
|
case runPure $ readOrg def s of |
|
Left err -> do |
|
tell [show err] |
|
pure (mempty, defaultFrontMatter) |
|
Right doc -> |
|
-- TODO: Merge Pandoc's Meta in here? |
|
pure (preparePandoc doc, defaultFrontMatter) |
|
|
|
parseNoteMarkdown :: (MonadIO m, MonadLogger m) => ScriptingEngine -> [FilePath] -> FilePath -> Text -> WriterT [Text] m (Pandoc, Aeson.Value) |
|
parseNoteMarkdown scriptingEngine pluginBaseDir fp md = do |
|
case Markdown.parseMarkdown fp md of |
|
Left err -> do |
|
tell [err] |
|
pure (mempty, defaultFrontMatter) |
|
Right (withAesonDefault defaultFrontMatter -> frontmatter, doc') -> do |
|
-- Apply the various transformation filters. |
|
-- |
|
-- Some are user-defined; some builtin. They operate on Pandoc, or the |
|
-- frontmatter meta. |
|
filterPaths <- fmap catMaybes $ forM (SData.lookupAeson @[FilePath] mempty ("pandoc" :| ["filters"]) frontmatter) $ \p -> do |
|
res :: [FilePath] <- flip mapMaybeM pluginBaseDir $ \baseDir -> do |
|
doesPathExist (baseDir </> p) >>= \case |
|
False -> do |
|
pure Nothing |
|
True -> |
|
pure $ Just $ baseDir </> p |
|
case res of |
|
[] -> do |
|
tell [toText $ "Pandoc filter " <> p <> " not found in any of: " <> show pluginBaseDir] |
|
pure Nothing |
|
(x : _) -> pure $ Just x |
|
|
|
doc <- applyPandocFilters scriptingEngine filterPaths $ preparePandoc doc' |
|
let meta = applyNoteMetaFilters doc frontmatter |
|
pure (doc, meta) |
|
where |
|
withAesonDefault default_ mv = |
|
fromMaybe default_ mv |
|
`SData.mergeAeson` default_ |
Though that does not seem related, would you know what is going on here @srid ?