forked from jgm/pandoc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Org reader: Fix emphasis rules for smart parsing
Smart quotes, ellipses, and dashes should behave like normal quotes, single dashes, and dots with respect to text markup parsing. The parser state was not updated properly in all cases, which has been fixed. Thanks to @conklech for reporting this issue. This fixes jgm#2513.
- Loading branch information
Showing
2 changed files
with
18 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
||
{- | | ||
Module : Text.Pandoc.Readers.Org | ||
Copyright : Copyright (C) 2014 Albert Krewinkel | ||
Copyright : Copyright (C) 2014-2015 Albert Krewinkel | ||
License : GNU GPL, version 2 or above | ||
Maintainer : Albert Krewinkel <[email protected]> | ||
|
@@ -1585,25 +1585,30 @@ smart :: OrgParser (F Inlines) | |
smart = do | ||
getOption readerSmart >>= guard | ||
doubleQuoted <|> singleQuoted <|> | ||
choice (map (return <$>) [orgApostrophe, dash, ellipses]) | ||
where orgApostrophe = | ||
choice (map (return <$>) [orgApostrophe, orgDash, orgEllipses]) | ||
where | ||
orgDash = dash <* updatePositions '-' | ||
orgEllipses = ellipses <* updatePositions '.' | ||
orgApostrophe = | ||
(char '\'' <|> char '\8217') <* updateLastPreCharPos | ||
<* updateLastForbiddenCharPos | ||
*> return (B.str "\x2019") | ||
|
||
singleQuoted :: OrgParser (F Inlines) | ||
singleQuoted = try $ do | ||
singleQuoteStart | ||
updatePositions '\'' | ||
withQuoteContext InSingleQuote $ | ||
fmap B.singleQuoted . trimInlinesF . mconcat <$> | ||
many1Till inline singleQuoteEnd | ||
many1Till inline (singleQuoteEnd <* updatePositions '\'') | ||
|
||
-- doubleQuoted will handle regular double-quoted sections, as well | ||
-- as dialogues with an open double-quote without a close double-quote | ||
-- in the same paragraph. | ||
doubleQuoted :: OrgParser (F Inlines) | ||
doubleQuoted = try $ do | ||
doubleQuoteStart | ||
updatePositions '"' | ||
contents <- mconcat <$> many (try $ notFollowedBy doubleQuoteEnd >> inline) | ||
(withQuoteContext InDoubleQuote $ (doubleQuoteEnd <* updateLastForbiddenCharPos) >> return | ||
(fmap B.doubleQuoted . trimInlinesF $ contents)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters