From 468737141a92faacb1e9a2f33081ff073251852d Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Mon, 1 Feb 2021 17:15:11 -0500 Subject: [PATCH] tags plugin: Fix inline tags regression --- neuron/neuron.cabal | 2 +- neuron/src/lib/Neuron/Plugin/Plugins/Tags.hs | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/neuron/neuron.cabal b/neuron/neuron.cabal index 586dbfb13..b0cbded65 100644 --- a/neuron/neuron.cabal +++ b/neuron/neuron.cabal @@ -1,7 +1,7 @@ cabal-version: 2.4 name: neuron -- This version must be in sync with what's in Default.dhall -version: 1.9.7.1 +version: 1.9.8.0 license: AGPL-3.0-only copyright: 2020 Sridhar Ratnakumar maintainer: srid@srid.ca diff --git a/neuron/src/lib/Neuron/Plugin/Plugins/Tags.hs b/neuron/src/lib/Neuron/Plugin/Plugins/Tags.hs index b2039a99e..0ad67b6cc 100644 --- a/neuron/src/lib/Neuron/Plugin/Plugins/Tags.hs +++ b/neuron/src/lib/Neuron/Plugin/Plugins/Tags.hs @@ -59,7 +59,7 @@ import Neuron.Zettelkasten.Graph.Type (ZettelGraph) import Neuron.Zettelkasten.Zettel import Reflex.Dom.Core hiding (count, mapMaybe, tag) import Reflex.Dom.Pandoc (PandocBuilder) -import Relude hiding (trace, traceShow, traceShowId) +import Relude import Text.Pandoc.Definition (Inline, Pandoc) import qualified Text.Pandoc.Util as Pandoc import qualified Text.Parsec as P @@ -239,8 +239,9 @@ renderQueryResult = \case renderTagTree $ TagTree.foldTagTree $ TagTree.tagTree res TagQuery_TagZettel tag :=> Identity () -> renderInlineTag tag mempty $ do - text "#" - text $ unTag tag + elClass "code" "inline-tag" $ do + text "#" + text $ unTag tag where -- TODO: Instead of doing this here, group the results in runQuery itself. groupZettelsByTagsMatching pats matches = @@ -320,10 +321,14 @@ parseTagQuerys myaml z = catMaybes $ allUrls <&> \(attrs, url) -> do parseQueryLink attrs url - tags = fromRight Set.empty $ case myaml of + tagsFromYaml = fromRight Set.empty $ case myaml of Nothing -> pure Set.empty Just yaml -> Set.fromList <$> M.runYamlParser (tagsParser yaml) - tagsData = ZettelTags tags tagLinks + inlineTags = Set.fromList $ + flip fmapMaybe tagLinks $ \case + Some (TagQuery_TagZettel t) -> Just t + _ -> Nothing + tagsData = ZettelTags (tagsFromYaml <> inlineTags) tagLinks in z {zettelPluginData = DMap.insert Tags (Identity tagsData) (zettelPluginData z)} tagsParser :: Y.Node Y.Pos -> Y.Parser [Tag]