@@ -42,6 +42,7 @@ import Data.Maybe
4242import Data.Monoid ((<>))
4343import Data.Ord (comparing)
4444import Data.Scientific (base10Exponent, coefficient)
45+import qualified Data.Set as Set
4546import Data.Text (Text)
4647import qualified Data.Text as T
4748import qualified Data.Vector as V
@@ -1688,32 +1689,22 @@ nonEndline = satisfy (/='\n')
16881689
16891690str :: PandocMonad m => MarkdownParser m (F Inlines)
16901691str = do
1691− result <- many1 alphaNum
1692+ result <- many1 (alphaNum <|> try (char '.' <* notFollowedBy (char '.')))
16921693 updateLastStrPos
1693− let spacesToNbr = map (\c -> if c == ' ' then '\160' else c)
1694− isSmart <- extensionEnabled Ext_smart <$> getOption readerExtensions
1695− if isSmart
1696− then case likelyAbbrev result of
1697− [] -> return $ return $ B.str result
1698− xs -> choice (map (\x ->
1699− try (string x >> oneOf " \n" >>
1700− lookAhead alphaNum >>
1701− return (return $ B.str
1702− $ result ++ spacesToNbr x ++ "\160"))) xs)
1703− <|> (return $ return $ B.str result)
1704− else return $ return $ B.str result
1705−
1706−-- | if the string matches the beginning of an abbreviation (before
1707−-- the first period, return strings that would finish the abbreviation.
1708−likelyAbbrev :: String -> [String]
1709−likelyAbbrev x =
1710− let abbrevs = [ "Mr.", "Mrs.", "Ms.", "Capt.", "Dr.", "Prof.",
1711− "Gen.", "Gov.", "e.g.", "i.e.", "Sgt.", "St.",
1712− "vol.", "vs.", "Sen.", "Rep.", "Pres.", "Hon.",
1713− "Rev.", "Ph.D.", "M.D.", "M.A.", "p.", "pp.",
1714− "ch.", "sec.", "cf.", "cp."]
1715− abbrPairs = map (break (=='.')) abbrevs
1716− in map snd $ filter (\(y,_) -> y == x) abbrPairs
1694+ (do guardEnabled Ext_smart
1695+ abbrevs <- getOption readerAbbreviations
1696+ if not (null result) && last result == '.' && result `Set.member` abbrevs
1697+ then try (do ils <- whitespace <|> endline
1698+ lookAhead alphaNum
1699+ return $ do
1700+ ils' <- ils
1701+ if ils' == B.space
1702+ then return (B.str result <> B.str "\160")
1703+ else -- linebreak or softbreak
1704+ return (ils' <> B.str result <> B.str "\160"))
1705+ <|> return (return (B.str result))
1706+ else return (return (B.str result)))
1707+ <|> return (return (B.str result))
17171708
17181709-- an endline character that can be treated as a space, not a structural break
17191710endline :: PandocMonad m => MarkdownParser m (F Inlines)