Skip to content

Commit

Permalink
Disallow tags ending with slash
Browse files Browse the repository at this point in the history
Resolves #172
  • Loading branch information
srid committed Oct 10, 2021
1 parent f956f55 commit 0ae24b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion emanote.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.4
name: emanote
version: 0.3.6.1
version: 0.3.7.0
license: AGPL-3.0-only
copyright: 2021 Sridhar Ratnakumar
maintainer: [email protected]
Expand Down
9 changes: 7 additions & 2 deletions src/Emanote/Pandoc/Markdown/Syntax/HashTag.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import qualified Commonmark.Pandoc as CP
import Commonmark.TokParsers (noneOfToks, symbol)
import qualified Data.Map.Strict as Map
import qualified Data.TagTree as TT
import qualified Data.Text as T
import Relude
import qualified Text.Pandoc.Builder as B
import qualified Text.Pandoc.Walk as W
Expand Down Expand Up @@ -76,7 +77,11 @@ hashTagSpec =
tag <- CM.untokenize <$> tagP
pure $ hashTag $ TT.Tag tag
tagP :: Monad m => P.ParsecT [CM.Tok] s m [CM.Tok]
tagP =
some (noneOfToks $ [Spaces, UnicodeSpace, LineEnd] <> fmap Symbol punctuation)
tagP = do
s <- some (noneOfToks disallowed)
-- A tag cannot end with a slash (which is a separator in hierarchical tags)
guard $ not $ "/" `T.isSuffixOf` CM.untokenize s
pure s
where
disallowed = [Spaces, UnicodeSpace, LineEnd] <> fmap Symbol punctuation
punctuation = "[];:,.?!"

0 comments on commit 0ae24b4

Please sign in to comment.