Skip to content

Commit

Permalink
Commonmark.Entity: export pEntity [API change].
Browse files Browse the repository at this point in the history
  • Loading branch information
jgm committed Mar 6, 2024
1 parent e579010 commit d3a486a
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions commonmark/src/Commonmark/Entity.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ module Commonmark.Entity
( lookupEntity
, charEntity
, numEntity
, pEntity
, unEntity
)
where

import Data.Functor.Identity (Identity)
import qualified Data.Map.Strict as Map
import Commonmark.TokParsers
import Commonmark.Tokens
Expand Down Expand Up @@ -2335,14 +2335,15 @@ numEntity = do

unEntity :: [Tok] -> Text
unEntity ts = untokenize $
case parse (many (pEntity' <|> anyTok)) "" ts of
case parse (many (pEntity <|> anyTok)) "" ts of
Left _ -> ts
Right ts' -> ts'
where pEntity' :: ParsecT [Tok] () Identity Tok
pEntity' = try $ do
pos <- getPosition
symbol '&'
ent <- untokenize <$> (numEntity <|> charEntity)
case lookupEntity ent of
Just s -> return $ Tok WordChars pos s
Nothing -> mzero

pEntity :: Monad m => ParsecT [Tok] s m Tok
pEntity = try $ do
pos <- getPosition
symbol '&'
ent <- untokenize <$> (numEntity <|> charEntity)
case lookupEntity ent of
Just s -> return $ Tok WordChars pos s
Nothing -> mzero

0 comments on commit d3a486a

Please sign in to comment.