-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Markdown: Awkward soft break after abbreviation between ( and newline #4635
Comments
This is actually a pretty common bug if you used hard line wrapping in your source document. It produces the error any time a line in your source document ends in an abbreviation prefixed by parenthesis:
produces output
I hard wrap at 78 characters in my source documents. On average for me, this produces ~3 errors per 8,000 words and of course it affects all output formats. |
A possible workaround is to use |
Here's the relevant code (in abbrevs <- getOption readerAbbreviations
if not (null result) && last result == '.' && result `Set.member` abbrevs
then try (do ils <- whitespace <|> endline
lookAhead alphaNum
return $ do
ils' <- ils
if ils' == B.space
then return (B.str result <> B.str "\160")
else -- linebreak or softbreak
return (ils' <> B.str result <> B.str "\160"))
<|> return (return (B.str result))
else return (return (B.str result))) The logic is this: when an abbreviation is followed by a space, we replace it by a nonbreaking space. When it is followed by a line break (soft or hard), we replace it by a nonbreaking space and move the line break before the abbreviation. That gives bad results when the abbreviation isn't itself preceded by a space. |
Note that with this new implementation, you can defeat the abbreviationization by using two spaces after the period. This commit removes support for moving abbreviations after soft breaks (#4635), so the abbreviation support won't work for abbreviations occuring at the end of a line. It seems better not to mess with the user's soft breaks, especially now that we have `--wrap=preserve`.
Test case:
Output:
( cf. Foo)
.A space has been added after the open parenthesis. More precisely, if the native output format is chosen, we see it's a
SoftBreak
:[Para [Str "(",SoftBreak,Str "cf.\160Foo)"]]
.This is a sufficiently rare case that it only occurred once in a 350 page document.
The text was updated successfully, but these errors were encountered: