@@ -33,7 +33,7 @@ module Text.Pandoc.Readers.Markdown (
3333
3434import Data.List ( transpose, isPrefixOf, isSuffixOf, lookup, sortBy, findIndex )
3535import Data.Ord ( comparing )
36−import Data.Char ( isAlphaNum )
36+import Data.Char ( isAlphaNum, isAlpha, isLower, isDigit )
3737import Data.Maybe ( fromMaybe )
3838import Text.Pandoc.Definition
3939import Text.Pandoc.Shared
@@ -697,7 +697,8 @@ table = simpleTable <|> multilineTable <?> "table"
697697
698698inline = choice inlineParsers <?> "inline"
699699
700−inlineParsers = [ str
700+inlineParsers = [ abbrev
701+ , str
701702 , smartPunctuation
702703 , whitespace
703704 , endline
@@ -792,6 +793,26 @@ subscript = failIfStrict >> enclosed (char '~') (char '~')
792793 (notFollowedBy' whitespace >> inline) >>= -- may not contain Space
793794 return . Subscript
794795
796+abbrev = failUnlessSmart >>
797+ (assumedAbbrev <|> knownAbbrev) >>= return . Str . (++ ".\160")
798+
799+-- an string of letters followed by a period that does not end a sentence
800+-- is assumed to be an abbreviation. It is assumed that sentences don't
801+-- start with lowercase letters or numerals.
802+assumedAbbrev = try $ do
803+ result <- many1 $ satisfy isAlpha
804+ string ". "
805+ lookAhead $ satisfy (\x -> isLower x || isDigit x)
806+ return result
807+
808+-- these strings are treated as abbreviations even if they are followed
809+-- by a capital letter (such as a name).
810+knownAbbrev = try $ do
811+ result <- oneOfStrings [ "Mr", "Mrs", "Ms", "Capt", "Dr", "Prof", "Gen",
812+ "Gov", "e.g", "i.e", "Sgt", "St", "vol", "vs" ]
813+ string ". "
814+ return result
815+
795816smartPunctuation = failUnlessSmart >>
796817 choice [ quoted, apostrophe, dash, ellipses ]
797818