]> granicus.if.org Git - multimarkdown/commitdiff
FIXED: Don't strip leading indent in fenced code blocks
authorFletcher T. Penney <fletcher@fletcherpenney.net>
Sat, 22 Jul 2017 21:13:44 +0000 (17:13 -0400)
committerFletcher T. Penney <fletcher@fletcherpenney.net>
Sat, 22 Jul 2017 21:13:44 +0000 (17:13 -0400)
Sources/libMultiMarkdown/mmd.c
tests/MMD6Tests/Fenced Code Blocks.fodt
tests/MMD6Tests/Fenced Code Blocks.html
tests/MMD6Tests/Fenced Code Blocks.htmlc
tests/MMD6Tests/Fenced Code Blocks.tex
tests/MMD6Tests/Fenced Code Blocks.text

index 634451c188c9a6fe598ba109cec5247f4b1b6359..bba97aa0c51cf85c3afa85fc1625c616fa818d22 100644 (file)
@@ -2026,7 +2026,7 @@ void strip_line_tokens_from_block(mmd_engine * e, token * block) {
 handle_line:
 
                                // Remove leading non-indent space from line
-                               if (l->child && l->child->type == NON_INDENT_SPACE) {
+                               if (block->type != BLOCK_CODE_FENCED && l->child && l->child->type == NON_INDENT_SPACE) {
                                        token_remove_first_child(l);
                                }
 
@@ -2034,7 +2034,7 @@ handle_line:
                        case LINE_INDENTED_SPACE:
 
                                // Strip leading indent (Only the first one)
-                               if (l->child && ((l->child->type == INDENT_SPACE) || (l->child->type == INDENT_TAB))) {
+                               if (block->type != BLOCK_CODE_FENCED && l->child && ((l->child->type == INDENT_SPACE) || (l->child->type == INDENT_TAB))) {
                                        token_remove_first_child(l);
                                }
 
index 9f48bffc7d1d0bc2089ff5578f4e93a96bf4387b..aad64e743a66eb4b8fbe520c361da2d6a0a046a8 100644 (file)
@@ -303,6 +303,8 @@ office:mimetype="application/vnd.oasis.opendocument.text">
 
 <text:p text:style-name="Preformatted Text">&lt;p&gt;foo&lt;/p&gt;<text:line-break/></text:p>
 
+<text:p text:style-name="Preformatted Text">foo<text:line-break/><text:line-break/><text:tab/>bar<text:line-break/><text:line-break/>bar<text:line-break/><text:line-break/>    foo<text:line-break/></text:p>
+
 <text:p text:style-name="Preformatted Text">foo<text:line-break/></text:p>
 </office:text>
 </office:body>
index 2b1c099e4d56fe7243feab19b39dd32e62c8a4ed..b048f38def6f2c94fc15a2cd92b5a65f12110978 100644 (file)
@@ -38,6 +38,15 @@ bar
 <pre><code>&lt;p&gt;foo&lt;/p&gt;
 </code></pre>
 
+<pre><code>foo
+
+       bar
+
+bar
+
+    foo
+</code></pre>
+
 <pre><code>foo
 </code></pre>
 
index af3aaa0c32e768b42e37aea7213c6cd75bf8fc6f..e0d5990f2035643b3d2d8eeab944c14549695222 100644 (file)
@@ -36,3 +36,16 @@ latex config:        article</p>
 
 <p>```
 foo</p>
+
+<pre><code>bar
+</code></pre>
+
+<p>bar</p>
+
+<pre><code>foo
+</code></pre>
+
+<p>```</p>
+
+<p>```
+foo</p>
index fe076153ca22b1a347f71277c6268ddeb90dbcbe..c770be1a280f91e0a19888b8c575196e8b9930b6 100644 (file)
@@ -43,6 +43,16 @@ bar
 <p>foo</p>
 \end{verbatim}
 
+\begin{verbatim}
+foo
+
+       bar
+
+bar
+
+    foo
+\end{verbatim}
+
 \begin{verbatim}
 foo
 \end{verbatim}
index 935ff16208c51611957377164c61f3ebfb1b2501..2919400a1b0c04943b6c9ee46de29caf71b4f6ad 100644 (file)
@@ -39,5 +39,16 @@ bar
 <p>foo</p>
 ```
 
+```
+foo
+
+       bar
+
+  bar
+
+    foo
+```
+
+
 ```
 foo