git.iko.soy/typeable/pandoc
on master help sign in
Fix parsing of citations and quotes after parentheses.

Starting with pandoc 2.4, citations and quoted inlines were no longer recognized after parentheses. This is because of commit 9b0bd4ec6f5c9125efb3e36232e6d1f6ac08a728, which is reverted here. The point of that commit was to allow relocation of soft line breaks to before an abbreviation, so that a nonbreaking space could be added after the abbreviation. Now we simply leave the soft line break in place, even though this means that we won't get a nonbreaking space after "Mr." at the end of a line (and in LaTeX this may result in a longer intersentential space). Those who care about this issue should take care not to end lines with an abbreviation, or to insert nonbreaking spaces manually. Closes #5099.

commitedc651059ee617cf36b511de080a646d2e6513a4 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 25 Nov 2018, 21:57 (8 years ago) parent839bd3c
4 files changed+17−19
src/Text/Pandoc/Readers/Markdown.hs+2−6 test/command/4635.md+2−2 test/command/5099.md+13 test/command/md-abbrevs.md−11
src/Text/Pandoc/Readers/Markdown.hs+2−6
@@ -1586,7 +1586,6 @@ symbol = do
15861586 <|> try (do lookAhead $ char '\\'
15871587 notFollowedBy' (() <$ rawTeXBlock)
15881588 char '\\')
1589− updateLastStrPos
15901589 return $ return $ B.str [result]
15911590
15921591-- parses inline code, between n `s and n `s
@@ -1633,7 +1632,7 @@ enclosure c = do
16331632 3 -> three c
16341633 2 -> two c mempty
16351634 1 -> one c mempty
1636− _ -> updateLastStrPos >> return (return $ B.str cs)
1635+ _ -> return (return $ B.str cs)
16371636
16381637ender :: PandocMonad m => Char -> Int -> MarkdownParser m ()
16391638ender c n = try $ do
@@ -1717,13 +1716,12 @@ nonEndline = satisfy (/='\n')
17171716
17181717str :: PandocMonad m => MarkdownParser m (F Inlines)
17191718str = do
1720− canRelocateSpace <- notAfterString
17211719 result <- many1 (alphaNum <|> try (char '.' <* notFollowedBy (char '.')))
17221720 updateLastStrPos
17231721 (do guardEnabled Ext_smart
17241722 abbrevs <- getOption readerAbbreviations
17251723 if not (null result) && last result == '.' && result `Set.member` abbrevs
1726− then try (do ils <- whitespace <|> endline
1724+ then try (do ils <- whitespace
17271725 -- ?? lookAhead alphaNum
17281726 -- replace space after with nonbreaking space
17291727 -- if softbreak, move before abbrev if possible (#4635)
@@ -1732,8 +1730,6 @@ str = do
17321730 case B.toList ils' of
17331731 [Space] ->
17341732 return (B.str result <> B.str "\160")
1735− [SoftBreak] | canRelocateSpace ->
1736− return (ils' <> B.str result <> B.str "\160")
17371733 _ -> return (B.str result <> ils'))
17381734 <|> return (return (B.str result))
17391735 else return (return (B.str result)))
test/command/4635.md+2−2
@@ -19,7 +19,7 @@ foo)
1919cf.
2020foo
2121^D
22−[Para [Str "cf.\160foo"]]
22+[Para [Str "cf.",SoftBreak,Str "foo"]]
2323```
2424
2525```
@@ -27,5 +27,5 @@ foo
2727a cf.
2828foo
2929^D
30−[Para [Str "a",SoftBreak,Str "cf.\160foo"]]
30+[Para [Str "a",Space,Str "cf.",SoftBreak,Str "foo"]]
3131```
test/command/5099.mdnew file+13
@@ -0,0 +1,13 @@
1+```
2+% pandoc -t native
3+(@citation
4+^D
5+[Para [Str "(",Cite [Citation {citationId = "citation", citationPrefix = [], citationSuffix = [], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 0}] [Str "@citation"]]]
6+```
7+
8+```
9+% pandoc -t native
10+('asd')
11+^D
12+[Para [Str "(",Quoted SingleQuote [Str "asd"],Str ")"]]
13+```
test/command/md-abbrevs.md−11
@@ -9,17 +9,6 @@ Mr. Bob
99[Para [Str "Mr.\160Bob"]]
1010```
1111
12−Here pandoc readjusts the softbreak so that the nonbreaking
13−space can be inserted:
14−
15−```
16−% pandoc -t native
17−Hi Mr.
18−Bob
19−^D
20−[Para [Str "Hi",SoftBreak,Str "Mr.\160Bob"]]
21−```
22−
2312If you don't want this to happen you can escape the period:
2413
2514```