Skip to content

Commit

Permalink
Use lastMay instead of reverse
Browse files Browse the repository at this point in the history
  • Loading branch information
josephcsible authored and jgm committed Dec 15, 2024
1 parent 9bb67d6 commit 58cc5cc
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/Text/Pandoc/Readers/Vimwiki.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import Data.List (isInfixOf)
import Data.Maybe
import Data.Text (Text)
import qualified Data.Text as T
import Safe (lastMay)
import Text.Pandoc.Builder (Blocks, Inlines, fromList, toList, trimInlines)
import qualified Text.Pandoc.Builder as B (blockQuote, bulletList, code,
codeBlockWith, definitionList,
Expand Down Expand Up @@ -510,9 +511,7 @@ strong = try $ do
notFollowedBy (oneOf spaceChars)
contents <- mconcat <$> many1Till inline'
(try (char '*' *> notFollowedBy alphaNum))
guard $ case reverse (toList contents) of
Space:_ -> False
_ -> True
guard $ lastMay (toList contents) /= Just Space
return $ B.spanWith (makeId contents, [], []) mempty <> B.strong contents

makeId :: Inlines -> Text
Expand All @@ -524,9 +523,7 @@ emph = try $ do
notFollowedBy (oneOf spaceChars)
contents <- mconcat <$> many1Till inline'
(try (char '_' *> notFollowedBy alphaNum))
guard $ case reverse (toList contents) of
Space:_ -> False
_ -> True
guard $ lastMay (toList contents) /= Just Space
return $ B.emph contents

strikeout :: PandocMonad m => VwParser m Inlines
Expand Down

0 comments on commit 58cc5cc

Please sign in to comment.