@@ -42,6 +42,7 @@ import Data.Maybe
42import Data.Monoid ((<>))
42import Data.Monoid ((<>))
43import Data.Ord (comparing)
43import Data.Ord (comparing)
44import Data.Scientific (base10Exponent, coefficient)
44import Data.Scientific (base10Exponent, coefficient)
45+import qualified Data.Set as Set
45import Data.Text (Text)
46import Data.Text (Text)
46import qualified Data.Text as T
47import qualified Data.Text as T
47import qualified Data.Vector as V
48import qualified Data.Vector as V
@@ -1688,32 +1689,22 @@ nonEndline = satisfy (/='\n')
1689str :: PandocMonad m => MarkdownParser m (F Inlines)
1690str :: PandocMonad m => MarkdownParser m (F Inlines)
1691− result <- many1 alphaNum
1692+ result <- many1 (alphaNum <|> try (char '.' <* notFollowedBy (char '.')))
1692 updateLastStrPos
1693 updateLastStrPos
1693− let spacesToNbr = map (\c -> if c == ' ' then '\160' else c)
1694+ (do guardEnabled Ext_smart
1694− isSmart <- extensionEnabled Ext_smart <$> getOption readerExtensions
1695+ abbrevs <- getOption readerAbbreviations
1695− if isSmart
1696+ if not (null result) && last result == '.' && result `Set.member` abbrevs
1696− then case likelyAbbrev result of
1697+ then try (do ils <- whitespace <|> endline
1697− [] -> return $ return $ B.str result
1698− xs -> choice (map (\x ->
1699− try (string x >> oneOf " \n" >>
1700− lookAhead alphaNum >>
1698+ lookAhead alphaNum
1701− return (return $ B.str
1699+ return $ do
1702− $ result ++ spacesToNbr x ++ "\160"))) xs)
1700+ ils' <- ils
1703− <|> (return $ return $ B.str result)
1702+ then return (B.str result <> B.str "\160")
1704− else return $ return $ B.str result
1703+ else -- linebreak or softbreak
1705−
1704+ return (ils' <> B.str result <> B.str "\160"))
1706−-- | if the string matches the beginning of an abbreviation (before
1705+ <|> return (return (B.str result))
1707−-- the first period, return strings that would finish the abbreviation.
1706+ else return (return (B.str result)))
1708−likelyAbbrev :: String -> [String]
1707+ <|> return (return (B.str result))
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
1718-- an endline character that can be treated as a space, not a structural break
1709-- an endline character that can be treated as a space, not a structural break
1719endline :: PandocMonad m => MarkdownParser m (F Inlines)
1710endline :: PandocMonad m => MarkdownParser m (F Inlines)