git.iko.soy/typeable/pandoc
on master help sign in
Muse reader: require block <literal> tags to be on separate lines
c6232d0Alexander Krotov
src/Text/Pandoc/Readers/Muse.hs+8−2
@@ -404,9 +404,15 @@ exampleTag = try $ do
404 return $ return $ B.codeBlockWith attr $ rchop $ intercalate "\n" $ dropSpacePrefix $ splitOn "\n" $ lchop contents
404 return $ return $ B.codeBlockWith attr $ rchop $ intercalate "\n" $ dropSpacePrefix $ splitOn "\n" $ lchop contents
405
405
406literalTag :: PandocMonad m => MuseParser m (F Blocks)
406literalTag :: PandocMonad m => MuseParser m (F Blocks)
407−literalTag =
407+literalTag = try $ do
408− (return . rawBlock) <$> htmlBlock "literal"
408+ many spaceChar
409+ (TagOpen _ attr, _) <- htmlTag (~== TagOpen "literal" [])
410+ manyTill spaceChar eol
411+ content <- manyTill anyChar endtag
412+ manyTill spaceChar eol
413+ return $ return $ rawBlock (htmlAttrToPandoc attr, content)
409 where
414 where
415+ endtag = void $ htmlTag (~== TagClose "literal")
410 -- FIXME: Emacs Muse inserts <literal> without style into all output formats, but we assume HTML
416 -- FIXME: Emacs Muse inserts <literal> without style into all output formats, but we assume HTML
411 format (_, _, kvs) = fromMaybe "html" $ lookup "style" kvs
417 format (_, _, kvs) = fromMaybe "html" $ lookup "style" kvs
412 rawBlock (attrs, content) = B.rawBlock (format attrs) $ rchop $ intercalate "\n" $ dropSpacePrefix $ splitOn "\n" $ lchop content
418 rawBlock (attrs, content) = B.rawBlock (format attrs) $ rchop $ intercalate "\n" $ dropSpacePrefix $ splitOn "\n" $ lchop content
test/Tests/Readers/Muse.hs+3
@@ -210,6 +210,9 @@ tests =
210 [ test emacsMuse "Inline literal"
210 [ test emacsMuse "Inline literal"
211 ("Foo<literal style=\"html\">lit</literal>bar" =?>
211 ("Foo<literal style=\"html\">lit</literal>bar" =?>
212 para (text "Foo" <> rawInline "html" "lit" <> text "bar"))
212 para (text "Foo" <> rawInline "html" "lit" <> text "bar"))
213+ , test emacsMuse "Single inline literal in paragraph"
214+ ("<literal style=\"html\">lit</literal>" =?>
215+ para (rawInline "html" "lit"))
213 ]
216 ]
214 ]
217 ]
215
218