From 84c2517741e6b05f389d44d12aa91bc4ba3baf49 Mon Sep 17 00:00:00 2001
From: "Fletcher T. Penney"
Date: Sat, 22 Jul 2017 17:13:44 -0400
Subject: [PATCH] FIXED: Don't strip leading indent in fenced code blocks
---
Sources/libMultiMarkdown/mmd.c | 4 ++--
tests/MMD6Tests/Fenced Code Blocks.fodt | 2 ++
tests/MMD6Tests/Fenced Code Blocks.html | 9 +++++++++
tests/MMD6Tests/Fenced Code Blocks.htmlc | 13 +++++++++++++
tests/MMD6Tests/Fenced Code Blocks.tex | 10 ++++++++++
tests/MMD6Tests/Fenced Code Blocks.text | 11 +++++++++++
6 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/Sources/libMultiMarkdown/mmd.c b/Sources/libMultiMarkdown/mmd.c
index 634451c..bba97aa 100644
--- a/Sources/libMultiMarkdown/mmd.c
+++ b/Sources/libMultiMarkdown/mmd.c
@@ -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);
}
diff --git a/tests/MMD6Tests/Fenced Code Blocks.fodt b/tests/MMD6Tests/Fenced Code Blocks.fodt
index 9f48bff..aad64e7 100644
--- a/tests/MMD6Tests/Fenced Code Blocks.fodt
+++ b/tests/MMD6Tests/Fenced Code Blocks.fodt
@@ -303,6 +303,8 @@ office:mimetype="application/vnd.oasis.opendocument.text">
<p>foo</p>
+foobarbar foo
+
foo
diff --git a/tests/MMD6Tests/Fenced Code Blocks.html b/tests/MMD6Tests/Fenced Code Blocks.html
index 2b1c099..b048f38 100644
--- a/tests/MMD6Tests/Fenced Code Blocks.html
+++ b/tests/MMD6Tests/Fenced Code Blocks.html
@@ -38,6 +38,15 @@ bar
<p>foo</p>
+foo
+
+ bar
+
+bar
+
+ foo
+
+
foo
diff --git a/tests/MMD6Tests/Fenced Code Blocks.htmlc b/tests/MMD6Tests/Fenced Code Blocks.htmlc
index af3aaa0..e0d5990 100644
--- a/tests/MMD6Tests/Fenced Code Blocks.htmlc
+++ b/tests/MMD6Tests/Fenced Code Blocks.htmlc
@@ -36,3 +36,16 @@ latex config: article
```
foo
+
+bar
+
+
+bar
+
+foo
+
+
+```
+
+```
+foo
diff --git a/tests/MMD6Tests/Fenced Code Blocks.tex b/tests/MMD6Tests/Fenced Code Blocks.tex
index fe07615..c770be1 100644
--- a/tests/MMD6Tests/Fenced Code Blocks.tex
+++ b/tests/MMD6Tests/Fenced Code Blocks.tex
@@ -43,6 +43,16 @@ bar
foo
\end{verbatim}
+\begin{verbatim}
+foo
+
+ bar
+
+bar
+
+ foo
+\end{verbatim}
+
\begin{verbatim}
foo
\end{verbatim}
diff --git a/tests/MMD6Tests/Fenced Code Blocks.text b/tests/MMD6Tests/Fenced Code Blocks.text
index 935ff16..2919400 100644
--- a/tests/MMD6Tests/Fenced Code Blocks.text
+++ b/tests/MMD6Tests/Fenced Code Blocks.text
@@ -39,5 +39,16 @@ bar
foo
```
+```
+foo
+
+ bar
+
+ bar
+
+ foo
+```
+
+
```
foo
--
2.50.1