From 046f5bcc8129334cd2a3945417abdc3a956318f2 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Tue, 21 Nov 2017 19:01:19 +0300 Subject: Muse reader: chop newlines after and before --- src/Text/Pandoc/Readers/Muse.hs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/Text/Pandoc/Readers') diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs index 89b23f5a3..9f1ba1e6c 100644 --- a/src/Text/Pandoc/Readers/Muse.hs +++ b/src/Text/Pandoc/Readers/Muse.hs @@ -228,24 +228,28 @@ example = try $ do contents <- manyTill anyChar $ try (optionMaybe blankline >> string "}}}") return $ return $ B.codeBlock contents -exampleTag :: PandocMonad m => MuseParser m (F Blocks) -exampleTag = do - (attr, contents) <- htmlElement "example" - return $ return $ B.codeBlockWith attr $ chop contents +-- Trim up to one newline from the beginning and the end, +-- in case opening and/or closing tags are on separate lines. +chop :: String -> String +chop = lchop . rchop where lchop s = case s of '\n':ss -> ss _ -> s rchop = reverse . lchop . reverse - -- Trim up to one newline from the beginning and the end, - -- in case opening and/or closing tags are on separate lines. - chop = lchop . rchop + +exampleTag :: PandocMonad m => MuseParser m (F Blocks) +exampleTag = do + (attr, contents) <- htmlElement "example" + return $ return $ B.codeBlockWith attr $ chop contents literal :: PandocMonad m => MuseParser m (F Blocks) -literal = (return . rawBlock) <$> htmlElement "literal" +literal = do + guardDisabled Ext_amuse -- Text::Amuse does not support + (return . rawBlock) <$> htmlElement "literal" where -- 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) content + rawBlock (attrs, content) = B.rawBlock (format attrs) $ chop content blockTag :: PandocMonad m => (Blocks -> Blocks) -- cgit v1.2.3