diff options
author | Alexander Krotov <ilabdsf@gmail.com> | 2017-11-21 19:01:19 +0300 |
---|---|---|
committer | Alexander Krotov <ilabdsf@gmail.com> | 2017-11-21 19:01:53 +0300 |
commit | 046f5bcc8129334cd2a3945417abdc3a956318f2 (patch) | |
tree | ac701682aad4916789a26a9685bda0572c9ed450 /src/Text/Pandoc | |
parent | 91d67334263058fa884793cb71d5ba9e7fcc4eb3 (diff) | |
download | pandoc-046f5bcc8129334cd2a3945417abdc3a956318f2.tar.gz |
Muse reader: chop newlines after <literal> and before </literal>
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/Muse.hs | 22 |
1 files changed, 13 insertions, 9 deletions
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 <literal> + (return . rawBlock) <$> htmlElement "literal" where -- FIXME: Emacs Muse inserts <literal> 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) |