aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2016-10-10 11:23:04 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2016-10-10 11:23:04 +0200
commitf4b7ab125e0eb034b4f90448f093d4c4a2284589 (patch)
tree54d28e7d835dd5911d70090dfd7b715724b5e01e /src/Text/Pandoc/Writers
parent5a0d91f1151285fdd09d85d83de3f28f7fa43ca8 (diff)
downloadpandoc-f4b7ab125e0eb034b4f90448f093d4c4a2284589.tar.gz
More checks for Ext_raw_html when rendering HTML in Markdown.
Previously we'd emit raw HTML tables even if the `raw_html` extension was disabled. Now we just emit `[TABLE]` if no table formats are enabled and raw HTML is not enabled. We also check for the `raw_html` extension before emiting a raw HTML block. Closes #3154.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs
index b04e33085..addcdf6a1 100644
--- a/src/Text/Pandoc/Writers/Markdown.hs
+++ b/src/Text/Pandoc/Writers/Markdown.hs
@@ -346,19 +346,20 @@ blockToMarkdown opts (Para [Image attr alt (src,'f':'i':'g':':':tit)]) =
blockToMarkdown opts (Para inlines) =
(<> blankline) `fmap` blockToMarkdown opts (Plain inlines)
blockToMarkdown opts (RawBlock f str)
- | f == "html" = do
+ | f == "markdown" = return $ text str <> text "\n"
+ | f == "html" && isEnabled Ext_raw_html opts = do
plain <- gets stPlain
return $ if plain
then empty
else if isEnabled Ext_markdown_attribute opts
then text (addMarkdownAttribute str) <> text "\n"
else text str <> text "\n"
- | f `elem` ["latex", "tex", "markdown"] = do
+ | f `elem` ["latex", "tex"] && isEnabled Ext_raw_tex opts = do
plain <- gets stPlain
return $ if plain
then empty
else text str <> text "\n"
-blockToMarkdown _ (RawBlock _ _) = return empty
+ | otherwise = return empty
blockToMarkdown opts HorizontalRule = do
return $ blankline <> text (replicate (writerColumns opts) '-') <> blankline
blockToMarkdown opts (Header level attr inlines) = do
@@ -460,9 +461,10 @@ blockToMarkdown opts t@(Table caption aligns widths headers rows) = do
| isEnabled Ext_grid_tables opts -> fmap (id,) $
gridTable opts (all null headers) aligns widths
rawHeaders rawRows
- | otherwise -> fmap (id,) $
+ | isEnabled Ext_raw_html opts -> fmap (id,) $
return $ text $ writeHtmlString def
$ Pandoc nullMeta [t]
+ | otherwise -> return $ (id, text "[TABLE]")
return $ nst $ tbl $$ blankline $$ caption'' $$ blankline
blockToMarkdown opts (BulletList items) = do
contents <- inList $ mapM (bulletListItemToMarkdown opts) items
@@ -680,7 +682,9 @@ blockListToMarkdown opts blocks =
isListBlock (OrderedList _ _) = True
isListBlock (DefinitionList _) = True
isListBlock _ = False
- commentSep = RawBlock "html" "<!-- -->\n"
+ commentSep = if isEnabled Ext_raw_html opts
+ then RawBlock "html" "<!-- -->\n"
+ else RawBlock "markdown" "&nbsp;"
-- | Get reference for target; if none exists, create unique one and return.
-- Prefer label if possible; otherwise, generate a unique key.