git.iko.soy/typeable/pandoc
on master help sign in
Org reader: fix parsers relying on parseFromString

Emphasis was not parsed when it followed directly after some block types (e.g., lists). The org reader uses a wrapper for the `parseFromString` function to handle org-specific state. The last position of a character allowed before emphasis was reset incorrectly in this wrapper. Emphasized text was not recognized when placed directly behind a block which the reader parses using `parseFromString`. Fixes: #4784

commit4e899eb9c886df2200551f69a3f593ab5258f2e2 authorAlbert Krewinkel <albert@zeitkraut.de> dateMon 23 Jul 2018, 22:05 (8 years ago) parenta858774
2 files changed+14−4
src/Text/Pandoc/Readers/Org/Parsing.hs+3−4 test/Tests/Readers/Org/Block/List.hs+11
src/Text/Pandoc/Readers/Org/Parsing.hs+3−4
@@ -137,14 +137,13 @@ anyLine =
137137 <* updateLastPreCharPos
138138 <* updateLastForbiddenCharPos
139139
140−-- The version Text.Pandoc.Parsing cannot be used, as we need additional parts
141−-- of the state saved and restored.
140+-- | Like @'Text.Pandoc.Parsing'@, but resets the position of the last character
141+-- allowed before emphasised text.
142142parseFromString :: Monad m => OrgParser m a -> String -> OrgParser m a
143143parseFromString parser str' = do
144− oldLastPreCharPos <- orgStateLastPreCharPos <$> getState
145144 updateState $ \s -> s{ orgStateLastPreCharPos = Nothing }
146145 result <- P.parseFromString parser str'
147− updateState $ \s -> s{ orgStateLastPreCharPos = oldLastPreCharPos }
146+ updateState $ \s -> s { orgStateLastPreCharPos = Nothing }
148147 return result
149148
150149-- | Skip one or more tab or space characters.
test/Tests/Readers/Org/Block/List.hs+11
@@ -243,4 +243,15 @@ tests =
243243 mconcat [ para "CLOSED: [2015-10-19 Mon 15:03]"
244244 , bulletList [ plain "Note taken on [2015-10-19 Mon 13:24]" ]
245245 ]
246+
247+ , "Markup after header and list" =:
248+ T.unlines [ "* headline"
249+ , "- list"
250+ , ""
251+ , "~variable name~"
252+ ] =?>
253+ mconcat [ headerWith ("headline", [], []) 1 "headline"
254+ , bulletList [ plain "list" ]
255+ , para (code "variable name")
256+ ]
246257 ]