From 2dde57569a13edd7fcb79dc80c8296b18560d88a Mon Sep 17 00:00:00 2001 From: Brian Leung Date: Thu, 17 Aug 2023 04:47:32 -0700 Subject: Org reader: allow example lines to end immediately after the colon See the regexp at https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/org-element.el?h=d1e4b9351941aa9241ab3aa0a34256376b7eca94#n2420. --- src/Text/Pandoc/Readers/Org/BlockStarts.hs | 2 +- test/command/8997.md | 77 ++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 test/command/8997.md diff --git a/src/Text/Pandoc/Readers/Org/BlockStarts.hs b/src/Text/Pandoc/Readers/Org/BlockStarts.hs index f0cef406d..5a2667289 100644 --- a/src/Text/Pandoc/Readers/Org/BlockStarts.hs +++ b/src/Text/Pandoc/Readers/Org/BlockStarts.hs @@ -115,7 +115,7 @@ commentLineStart = try $ skipSpaces <* string "#" <* lookAhead (oneOf " \n") exampleLineStart :: Monad m => OrgParser m () -exampleLineStart = () <$ try (skipSpaces *> string ": ") +exampleLineStart = () <$ try (skipSpaces *> char ':' *> (void (char ' ') <|> lookAhead eol)) noteMarker :: Monad m => OrgParser m Text noteMarker = try $ do diff --git a/test/command/8997.md b/test/command/8997.md new file mode 100644 index 000000000..60e39ed7e --- /dev/null +++ b/test/command/8997.md @@ -0,0 +1,77 @@ +``` +% pandoc -f org -t native +* has space after second colon +: aaa +: +: bbb + + +* has no space after second colon +: aaa +: +: bbb +^D +[ Header + 1 + ( "has-space-after-second-colon" , [] , [] ) + [ Str "has" + , Space + , Str "space" + , Space + , Str "after" + , Space + , Str "second" + , Space + , Str "colon" + ] +, CodeBlock ( "" , [ "example" ] , [] ) "aaa\n\nbbb\n" +, Header + 1 + ( "has-no-space-after-second-colon" , [] , [] ) + [ Str "has" + , Space + , Str "no" + , Space + , Str "space" + , Space + , Str "after" + , Space + , Str "second" + , Space + , Str "colon" + ] +, CodeBlock ( "" , [ "example" ] , [] ) "aaa\n\nbbb\n" +] +``` + +``` +% pandoc -f org -t native +* only the colon +: + +* only the colon and a space +: +^D +[ Header + 1 + ( "only-the-colon" , [] , [] ) + [ Str "only" , Space , Str "the" , Space , Str "colon" ] +, CodeBlock ( "" , [ "example" ] , [] ) "\n" +, Header + 1 + ( "only-the-colon-and-a-space" , [] , [] ) + [ Str "only" + , Space + , Str "the" + , Space + , Str "colon" + , Space + , Str "and" + , Space + , Str "a" + , Space + , Str "space" + ] +, CodeBlock ( "" , [ "example" ] , [] ) "\n" +] +``` -- cgit v1.2.3