git.iko.soy/typeable/pandoc
on master help sign in
Org reader: fix parsing of verbatim inlines

Org rules for allowed characters before or after markup chars were not checked for verbatim text. This resultet in wrong parsing outcomes of if the verbatim text contained e.g. space enclosed markup characters as part of the text (`=is_substr = True=`). Forcing the parser to update the positions of allowed/forbidden markup border characters fixes this. This fixes #3016.

commit529146decf7f0e390964bb7aa709082af6e8639b authorAlbert Krewinkel <albert@zeitkraut.de> dateThu 14 Jul 2016, 13:23 (10 years ago) parent106786e
2 files changed+7−2
src/Text/Pandoc/Readers/Org/Inlines.hs+4−2 tests/Tests/Readers/Org.hs+3
src/Text/Pandoc/Readers/Org/Inlines.hs+4−2
@@ -614,7 +614,7 @@ displayMath = return . B.displayMath <$> choice [ rawMathBetween "\\[" "\\]"
614614 ]
615615
616616updatePositions :: Char
617− -> OrgParser (Char)
617+ -> OrgParser Char
618618updatePositions c = do
619619 when (c `elem` emphasisPreChars) updateLastPreCharPos
620620 when (c `elem` emphasisForbiddenBorderChars) updateLastForbiddenCharPos
@@ -637,7 +637,9 @@ verbatimBetween :: Char
637637 -> OrgParser String
638638verbatimBetween c = try $
639639 emphasisStart c *>
640− many1TillNOrLessNewlines 1 (noneOf "\n\r") (emphasisEnd c)
640+ many1TillNOrLessNewlines 1 verbatimChar (emphasisEnd c)
641+ where
642+ verbatimChar = noneOf "\n\r" >>= updatePositions
641643
642644-- | Parses a raw string delimited by @c@ using Org's math rules
643645mathStringBetween :: Char
tests/Tests/Readers/Org.hs+3
@@ -185,6 +185,9 @@ tests =
185185 , "3" <> subscript "{}"
186186 , "4" <> superscript ("(a(" <> strong "b(c" <> ")d))")
187187 ])
188+ , "Verbatim text can contain equal signes (=)" =:
189+ "=is_subst = True=" =?>
190+ para (code "is_subst = True")
188191
189192 , "Image" =:
190193 "[[./sunset.jpg]]" =?>