stripTags :: Char -> Char -> (Text -> Bool) -> A.Parser Text
stripTags o c p = do
    (pre, tag) <- over _1 T.pack <$> till' A.anyChar tagOpen
    (mins, mmid) <- (,) <$> maybeTags <*> fmap Just (tillTagClose tag)
    mend <- maybeTags

    let mQuote = if p tag then Nothing else Just ()

    return . T.concat $ catMaybes
           [ Just pre, mins <* mQuote
           , (mmid <* mQuote) <|> Just "\n", mend
           ]
  where
    tagOpen = do
        A.char o
        t <- A.takeWhile (`notElem` ['=', c, ' '])
        A.skipWhile (/= c)
        A.char c
        return t
    tagClose t = A.char o >> "/" *> A.string t >> A.char c
    tillTagClose t = T.pack <$> A.manyTill' A.anyChar (tagClose t)
    maybeTags = fmap Just (stripTags o c p) <|> return Nothing
stripTags :: Char -> Char -> (Text -> Bool) -> A.Parser Text
stripTags o c p = do
    (pre, tag) <- over _1 T.pack <$> till' A.anyChar tagOpen
    (mins, mmid) <- (,) <$> maybeTags <*> fmap Just (tillTagClose tag)
    mend <- maybeTags

    let mQuote = if p tag then Nothing else Just ()

    return . T.concat $ catMaybes
           [ Just pre, mins <* mQuote
           , (mmid <* mQuote) <|> Just "\n", mend
           ]
  where
    tagOpen = do
        A.char o
        t <- A.takeWhile (`notElem` ['=', c, ' '])
        A.skipWhile (/= c)
        A.char c
        return t
    tagClose t = A.char o >> "/" *> A.string t >> A.char c
    tillTagClose t = T.pack <$> A.manyTill' A.anyChar (tagClose t)
    maybeTags = fmap Just (stripTags o c p) <|> return Nothing
stripTags o c p = do
    (pre, tag) <- over _1 T.pack <$> till' A.anyChar tagOpen
    (mins, mmid) <- (,) <$> maybeTags <*> fmap Just (tillTagClose tag)
    mend <- maybeTags

    let mQuote = if p tag then Nothing else Just ()

    return . T.concat $ catMaybes
           [ Just pre, mins <* mQuote
           , (mmid <* mQuote) <|> Just "\n", mend
           ]
  where
    tagOpen = do
        A.char o
        t <- A.takeWhile (`notElem` ['=', c, ' '])
        A.skipWhile (/= c)
        A.char c
        return t
    tagClose t = A.char o >> "/" *> A.string t >> A.char c
    tillTagClose t = T.pack <$> A.manyTill' A.anyChar (tagClose t)
    maybeTags = fmap Just (stripTags o c p) <|> return Nothing