From c6232d0f7d4aa18db4870b1fdb8ba701822e2889 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sun, 25 Mar 2018 17:27:54 +0300 Subject: Muse reader: require block tags to be on separate lines --- src/Text/Pandoc/Readers/Muse.hs | 10 ++++++++-- test/Tests/Readers/Muse.hs | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs index c9157b7d3..d40e74c96 100644 --- a/src/Text/Pandoc/Readers/Muse.hs +++ b/src/Text/Pandoc/Readers/Muse.hs @@ -404,9 +404,15 @@ exampleTag = try $ do return $ return $ B.codeBlockWith attr $ rchop $ intercalate "\n" $ dropSpacePrefix $ splitOn "\n" $ lchop contents literalTag :: PandocMonad m => MuseParser m (F Blocks) -literalTag = - (return . rawBlock) <$> htmlBlock "literal" +literalTag = try $ do + many spaceChar + (TagOpen _ attr, _) <- htmlTag (~== TagOpen "literal" []) + manyTill spaceChar eol + content <- manyTill anyChar endtag + manyTill spaceChar eol + return $ return $ rawBlock (htmlAttrToPandoc attr, content) where + endtag = void $ htmlTag (~== TagClose "literal") -- FIXME: Emacs Muse inserts without style into all output formats, but we assume HTML format (_, _, kvs) = fromMaybe "html" $ lookup "style" kvs rawBlock (attrs, content) = B.rawBlock (format attrs) $ rchop $ intercalate "\n" $ dropSpacePrefix $ splitOn "\n" $ lchop content diff --git a/test/Tests/Readers/Muse.hs b/test/Tests/Readers/Muse.hs index 45dd6bc34..3dc9b0917 100644 --- a/test/Tests/Readers/Muse.hs +++ b/test/Tests/Readers/Muse.hs @@ -210,6 +210,9 @@ tests = [ test emacsMuse "Inline literal" ("Foolitbar" =?> para (text "Foo" <> rawInline "html" "lit" <> text "bar")) + , test emacsMuse "Single inline literal in paragraph" + ("lit" =?> + para (rawInline "html" "lit")) ] ] -- cgit v1.2.3