19 lines
415 B
Haskell
19 lines
415 B
Haskell
{-# LANGUAGE ApplicativeDo #-}
|
|
module Tags (parseTags) where
|
|
|
|
import qualified Data.Attoparsec.Text as A
|
|
import Data.Attoparsec.Text (Parser)
|
|
import Data.Text (Text)
|
|
import Data.Either (fromRight)
|
|
|
|
tag :: Parser Text
|
|
tag = do
|
|
A.skipWhile (/= '[')
|
|
A.char '[' *> A.takeWhile (/= ']') <* A.char ']'
|
|
|
|
tags :: Parser [Text]
|
|
tags = A.many1 tag
|
|
|
|
parseTags :: Text -> [Text]
|
|
parseTags = fromRight [] . A.parseOnly tags
|