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 9b0bd4ec6f,
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.
This commit is contained in:
John MacFarlane
2018-11-25 21:57:18 -08:00
parent 839bd3cfe6
commit edc651059e
4 changed files with 17 additions and 19 deletions
+2 -6
View File
@@ -1586,7 +1586,6 @@ symbol = do
<|> try (do lookAhead $ char '\\'
notFollowedBy' (() <$ rawTeXBlock)
char '\\')
updateLastStrPos
return $ return $ B.str [result]
-- parses inline code, between n `s and n `s
@@ -1633,7 +1632,7 @@ enclosure c = do
3 -> three c
2 -> two c mempty
1 -> one c mempty
_ -> updateLastStrPos >> return (return $ B.str cs)
_ -> return (return $ B.str cs)
ender :: PandocMonad m => Char -> Int -> MarkdownParser m ()
ender c n = try $ do
@@ -1717,13 +1716,12 @@ nonEndline = satisfy (/='\n')
str :: PandocMonad m => MarkdownParser m (F Inlines)
str = do
canRelocateSpace <- notAfterString
result <- many1 (alphaNum <|> try (char '.' <* notFollowedBy (char '.')))
updateLastStrPos
(do guardEnabled Ext_smart
abbrevs <- getOption readerAbbreviations
if not (null result) && last result == '.' && result `Set.member` abbrevs
then try (do ils <- whitespace <|> endline
then try (do ils <- whitespace
-- ?? lookAhead alphaNum
-- replace space after with nonbreaking space
-- if softbreak, move before abbrev if possible (#4635)
@@ -1732,8 +1730,6 @@ str = do
case B.toList ils' of
[Space] ->
return (B.str result <> B.str "\160")
[SoftBreak] | canRelocateSpace ->
return (ils' <> B.str result <> B.str "\160")
_ -> return (B.str result <> ils'))
<|> return (return (B.str result))
else return (return (B.str result)))
+2 -2
View File
@@ -19,7 +19,7 @@ foo)
cf.
foo
^D
[Para [Str "cf.\160foo"]]
[Para [Str "cf.",SoftBreak,Str "foo"]]
```
```
@@ -27,5 +27,5 @@ foo
a cf.
foo
^D
[Para [Str "a",SoftBreak,Str "cf.\160foo"]]
[Para [Str "a",Space,Str "cf.",SoftBreak,Str "foo"]]
```
+13
View File
@@ -0,0 +1,13 @@
```
% pandoc -t native
(@citation
^D
[Para [Str "(",Cite [Citation {citationId = "citation", citationPrefix = [], citationSuffix = [], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 0}] [Str "@citation"]]]
```
```
% pandoc -t native
('asd')
^D
[Para [Str "(",Quoted SingleQuote [Str "asd"],Str ")"]]
```
-11
View File
@@ -9,17 +9,6 @@ Mr. Bob
[Para [Str "Mr.\160Bob"]]
```
Here pandoc readjusts the softbreak so that the nonbreaking
space can be inserted:
```
% pandoc -t native
Hi Mr.
Bob
^D
[Para [Str "Hi",SoftBreak,Str "Mr.\160Bob"]]
```
If you don't want this to happen you can escape the period:
```