git.iko.soy/typeable/pandoc
on master help sign in
Muse reader: remove space prefix from <literal> tag contents
64f8c5dAlexander Krotov
src/Text/Pandoc/Readers/Muse.hs+3−6
@@ -379,16 +379,13 @@ example = try $ do
379 contents <- manyTill anyChar $ try (optional blankline >> string "}}}")
379 contents <- manyTill anyChar $ try (optional blankline >> string "}}}")
380 return $ return $ B.codeBlock contents
380 return $ return $ B.codeBlock contents
381
381
382−-- Trim up to one newline from the beginning and the end,
382+-- Trim up to one newline from the beginning of the string.
383−-- in case opening and/or closing tags are on separate lines.
384−chop :: String -> String
385−chop = lchop . rchop
386−
387lchop :: String -> String
383lchop :: String -> String
388lchop s = case s of
384lchop s = case s of
389 '\n':ss -> ss
385 '\n':ss -> ss
390 _ -> s
386 _ -> s
391
387
388+-- Trim up to one newline from the end of the string.
392rchop :: String -> String
389rchop :: String -> String
393rchop = reverse . lchop . reverse
390rchop = reverse . lchop . reverse
394
391
@@ -410,7 +407,7 @@ literalTag = do
410 where
407 where
411 -- FIXME: Emacs Muse inserts <literal> without style into all output formats, but we assume HTML
408 -- FIXME: Emacs Muse inserts <literal> without style into all output formats, but we assume HTML
412 format (_, _, kvs) = fromMaybe "html" $ lookup "style" kvs
409 format (_, _, kvs) = fromMaybe "html" $ lookup "style" kvs
413− rawBlock (attrs, content) = B.rawBlock (format attrs) $ chop content
410+ rawBlock (attrs, content) = B.rawBlock (format attrs) $ rchop $ intercalate "\n" $ dropSpacePrefix $ splitOn "\n" $ lchop content
414
411
415-- <center> tag is ignored
412-- <center> tag is ignored
416centerTag :: PandocMonad m => MuseParser m (F Blocks)
413centerTag :: PandocMonad m => MuseParser m (F Blocks)