git.iko.soy/typeable/pandoc
on master help sign in
Markdown writer: prefer using raw_attribute when enabled.
28cad16John MacFarlane
src/Text/Pandoc/Writers/Markdown.hs+2−2
@@ -467,6 +467,7 @@ blockToMarkdown' opts b@(RawBlock f str) = do
467 let renderEmpty = mempty <$ report (BlockNotRendered b)
467 let renderEmpty = mempty <$ report (BlockNotRendered b)
468 case () of
468 case () of
469 _ | plain -> renderEmpty
469 _ | plain -> renderEmpty
470+ | isEnabled Ext_raw_attribute opts -> rawAttribBlock
470 | f `elem` ["markdown", "markdown_github", "markdown_phpextra",
471 | f `elem` ["markdown", "markdown_github", "markdown_phpextra",
471 "markdown_mmd", "markdown_strict"] ->
472 "markdown_mmd", "markdown_strict"] ->
472 return $ text str <> text "\n"
473 return $ text str <> text "\n"
@@ -484,7 +485,6 @@ blockToMarkdown' opts b@(RawBlock f str) = do
484 text str <> text "\n"
485 text str <> text "\n"
485 | isEnabled Ext_raw_attribute opts -> rawAttribBlock
486 | isEnabled Ext_raw_attribute opts -> rawAttribBlock
486 | otherwise -> renderEmpty
487 | otherwise -> renderEmpty
487− | isEnabled Ext_raw_attribute opts -> rawAttribBlock
488 | otherwise -> renderEmpty
488 | otherwise -> renderEmpty
489blockToMarkdown' opts HorizontalRule = do
489blockToMarkdown' opts HorizontalRule = do
490 return $ blankline <> text (replicate (writerColumns opts) '-') <> blankline
490 return $ blankline <> text (replicate (writerColumns opts) '-') <> blankline
@@ -1152,6 +1152,7 @@ inlineToMarkdown opts il@(RawInline f str) = do
1152 | f `elem` ["markdown", "markdown_github", "markdown_phpextra",
1152 | f `elem` ["markdown", "markdown_github", "markdown_phpextra",
1153 "markdown_mmd", "markdown_strict"] ->
1153 "markdown_mmd", "markdown_strict"] ->
1154 return $ text str
1154 return $ text str
1155+ | isEnabled Ext_raw_attribute opts -> rawAttribInline
1155 | f `elem` ["html", "html5", "html4"] ->
1156 | f `elem` ["html", "html5", "html4"] ->
1156 case () of
1157 case () of
1157 _ | isEnabled Ext_raw_html opts -> return $ text str
1158 _ | isEnabled Ext_raw_html opts -> return $ text str
@@ -1162,7 +1163,6 @@ inlineToMarkdown opts il@(RawInline f str) = do
1162 _ | isEnabled Ext_raw_tex opts -> return $ text str
1163 _ | isEnabled Ext_raw_tex opts -> return $ text str
1163 | isEnabled Ext_raw_attribute opts -> rawAttribInline
1164 | isEnabled Ext_raw_attribute opts -> rawAttribInline
1164 | otherwise -> renderEmpty
1165 | otherwise -> renderEmpty
1165− | isEnabled Ext_raw_attribute opts -> rawAttribInline
1166 | otherwise -> renderEmpty
1166 | otherwise -> renderEmpty
1167inlineToMarkdown opts (LineBreak) = do
1167inlineToMarkdown opts (LineBreak) = do
1168 plain <- asks envPlain
1168 plain <- asks envPlain
test/Tests/Writers/Markdown.hs+1−1
@@ -40,7 +40,7 @@ infix 4 =:
40tests :: [TestTree]
40tests :: [TestTree]
41tests = [ "indented code after list"
41tests = [ "indented code after list"
42 =: (orderedList [ para "one" <> para "two" ] <> codeBlock "test")
42 =: (orderedList [ para "one" <> para "two" ] <> codeBlock "test")
43− =?> "1. one\n\n two\n\n<!-- -->\n\n test"
43+ =?> "1. one\n\n two\n\n```{=html}\n<!-- -->\n```\n test"
44 , "list with tight sublist"
44 , "list with tight sublist"
45 =: bulletList [ plain "foo" <> bulletList [ plain "bar" ],
45 =: bulletList [ plain "foo" <> bulletList [ plain "bar" ],
46 plain "baz" ]
46 plain "baz" ]
test/command/4164.md+1−1
@@ -12,7 +12,7 @@ Here is inline html:
12
12
13<div>
13<div>
14
14
15−<balise> bla bla
15+`<balise>`{=html} bla bla
16
16
17</div>
17</div>
18
18
test/command/macros.md+5−5
@@ -1,5 +1,5 @@
1```
1```
2−% pandoc -f markdown+latex_macros -t markdown
2+% pandoc -f markdown+latex_macros -t markdown+raw_tex-raw_attribute
3\newcommand{\my}{\phi}
3\newcommand{\my}{\phi}
4$\my+\my$
4$\my+\my$
5^D
5^D
@@ -9,7 +9,7 @@ $\phi+\phi$
9```
9```
10
10
11```
11```
12−% pandoc -f markdown-latex_macros -t markdown
12+% pandoc -f markdown-latex_macros -t markdown+raw_tex-raw_attribute
13\newcommand{\my}{\phi}
13\newcommand{\my}{\phi}
14$\my+\my$
14$\my+\my$
15^D
15^D
@@ -70,7 +70,7 @@ x &= y\\\end{aligned}\]
70```
70```
71
71
72```
72```
73−% pandoc -f markdown+latex_macros -t markdown
73+% pandoc -f markdown+latex_macros -t markdown+raw_tex-raw_attribute
74\newcommand{\my}{\phi}
74\newcommand{\my}{\phi}
75\begin{equation}
75\begin{equation}
76\my+\my
76\my+\my
@@ -84,7 +84,7 @@ x &= y\\\end{aligned}\]
84```
84```
85
85
86```
86```
87−% pandoc -f markdown-latex_macros -t markdown
87+% pandoc -f markdown-latex_macros -t markdown+raw_tex-raw_attribute
88\newcommand{\my}{\phi}
88\newcommand{\my}{\phi}
89\begin{equation}
89\begin{equation}
90\my+\my
90\my+\my
@@ -98,7 +98,7 @@ x &= y\\\end{aligned}\]
98```
98```
99
99
100```
100```
101−% pandoc -f markdown+latex_macros -t markdown
101+% pandoc -f markdown+latex_macros -t markdown+raw_tex-raw_attribute
102\newcommand{\my}{\emph{a}}
102\newcommand{\my}{\emph{a}}
103\my
103\my
104^D
104^D
test/command/parse-raw.md+2−2
@@ -2,7 +2,7 @@
2% pandoc -f latex+raw_tex -t markdown
2% pandoc -f latex+raw_tex -t markdown
3\emph{Hi \foo{there}}
3\emph{Hi \foo{there}}
4^D
4^D
5−*Hi \foo{there}*
5+*Hi `\foo{there}`{=latex}*
6```
6```
7
7
8```
8```
@@ -16,7 +16,7 @@
16% pandoc -f html+raw_html -t markdown
16% pandoc -f html+raw_html -t markdown
17<em>Hi <blink>there</blink></em>
17<em>Hi <blink>there</blink></em>
18^D
18^D
19−*Hi <blink>there</blink>*
19+*Hi `<blink>`{=html}there`</blink>`{=html}*
20```
20```
21
21
22```
22```
test/writer.markdown+47−5
@@ -399,18 +399,35 @@ bar
399
399
400Interpreted markdown in a table:
400Interpreted markdown in a table:
401
401
402+```{=html}
402<table>
403<table>
404+```
405+```{=html}
403<tr>
406<tr>
407+```
408+```{=html}
404<td>
409<td>
410+```
405This is *emphasized*
411This is *emphasized*
412+```{=html}
406</td>
413</td>
414+```
415+```{=html}
407<td>
416<td>
417+```
408And this is **strong**
418And this is **strong**
419+```{=html}
409</td>
420</td>
421+```
422+```{=html}
410</tr>
423</tr>
424+```
425+```{=html}
411</table>
426</table>
427+```
428+```{=html}
412<script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
429<script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
413−
430+```
414Here's a simple block:
431Here's a simple block:
415
432
416<div>
433<div>
@@ -447,41 +464,64 @@ foo
447
464
448This should just be an HTML comment:
465This should just be an HTML comment:
449
466
467+```{=html}
450<!-- Comment -->
468<!-- Comment -->
451−
469+```
452Multiline:
470Multiline:
453
471
472+```{=html}
454<!--
473<!--
455Blah
474Blah
456Blah
475Blah
457-->
476-->
477+```
478+```{=html}
458<!--
479<!--
459 This is another comment.
480 This is another comment.
460-->
481-->
461−
482+```
462Code block:
483Code block:
463
484
464 <!-- Comment -->
485 <!-- Comment -->
465
486
466Just plain comment, with trailing spaces on the line:
487Just plain comment, with trailing spaces on the line:
467
488
489+```{=html}
468<!-- foo -->
490<!-- foo -->
469−
491+```
470Code:
492Code:
471
493
472 <hr />
494 <hr />
473
495
474Hr's:
496Hr's:
475
497
498+```{=html}
476<hr>
499<hr>
500+```
501+```{=html}
477<hr />
502<hr />
503+```
504+```{=html}
478<hr />
505<hr />
506+```
507+```{=html}
479<hr>
508<hr>
509+```
510+```{=html}
480<hr />
511<hr />
512+```
513+```{=html}
481<hr />
514<hr />
515+```
516+```{=html}
482<hr class="foo" id="bar" />
517<hr class="foo" id="bar" />
518+```
519+```{=html}
483<hr class="foo" id="bar" />
520<hr class="foo" id="bar" />
521+```
522+```{=html}
484<hr class="foo" id="bar">
523<hr class="foo" id="bar">
524+```
485
525
486------------------------------------------------------------------------------
526------------------------------------------------------------------------------
487
527
@@ -540,7 +580,7 @@ Ellipses...and...and....
540LaTeX
580LaTeX
541=====
581=====
542
582
543−- \cite[22-23]{smith.1899}
583+- `\cite[22-23]{smith.1899}`{=tex}
544- $2+2=4$
584- $2+2=4$
545- $x \in y$
585- $x \in y$
546- $\alpha \wedge \omega$
586- $\alpha \wedge \omega$
@@ -560,11 +600,13 @@ These shouldn't be math:
560
600
561Here's a LaTeX table:
601Here's a LaTeX table:
562
602
603+```{=tex}
563\begin{tabular}{|l|l|}\hline
604\begin{tabular}{|l|l|}\hline
564Animal & Number \\ \hline
605Animal & Number \\ \hline
565Dog & 2 \\
606Dog & 2 \\
566Cat & 1 \\ \hline
607Cat & 1 \\ \hline
567\end{tabular}
608\end{tabular}
609+```
568
610
569------------------------------------------------------------------------------
611------------------------------------------------------------------------------
570
612