Commit c595c2ed0076616856634332c35a7a3c851b287c

Martin Mitas 2020-07-30T08:38:19

md_process_verbatim_block_contents: Fix off by 1 error. This caused outputting wrong indentation inside a fenced code blocks for lines indented with mor ethan 16 spaces. Fixes #124.

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 253a511..4148dd0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,8 @@ Fixes:
    Fix HTML renderer's `MD_HTML_FLAG_VERBATIM_ENTITIES` flag, exposed in the
    `md2html` utility via `--fverbatim-entities`.
 
+ * [#124](https://github.com/mity/md4c/issues/124):
+   Fix handling of indentation of 16 or more spaces in the fenced code blocks.
 
 ## Version 0.4.4
 
diff --git a/src/md4c.c b/src/md4c.c
index 4abd7aa..9fbc715 100644
--- a/src/md4c.c
+++ b/src/md4c.c
@@ -4579,9 +4579,9 @@ md_process_verbatim_block_contents(MD_CTX* ctx, MD_TEXTTYPE text_type, const MD_
         MD_ASSERT(indent >= 0);
 
         /* Output code indentation. */
-        while(indent > (int) SIZEOF_ARRAY(indent_chunk_str)) {
+        while(indent > (int) indent_chunk_size) {
             MD_TEXT(text_type, indent_chunk_str, indent_chunk_size);
-            indent -= SIZEOF_ARRAY(indent_chunk_str);
+            indent -= indent_chunk_size;
         }
         if(indent > 0)
             MD_TEXT(text_type, indent_chunk_str, indent);
diff --git a/test/coverage.txt b/test/coverage.txt
index cffdf63..8367759 100644
--- a/test/coverage.txt
+++ b/test/coverage.txt
@@ -266,6 +266,24 @@ foo
 ````````````````````````````````
 
 
+### [Issue 124](https://github.com/mity/md4c/issues/124)
+
+```````````````````````````````` example
+~~~
+                x
+~~~
+
+~~~
+                 x
+~~~
+.
+<pre><code>                x
+</code></pre>
+<pre><code>                 x
+</code></pre>
+````````````````````````````````
+
+
 ## Code coverage
 
 ### `md_is_unicode_whitespace__()`