Allow indented code block to follow any block except paragraph without a blank line. Fixes #200.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
diff --git a/src/md4c.c b/src/md4c.c
index b433f76..3dbf929 100644
--- a/src/md4c.c
+++ b/src/md4c.c
@@ -5990,11 +5990,8 @@ md_analyze_line(MD_CTX* ctx, OFF beg, OFF* p_end,
/* Check for indented code.
* Note indented code block cannot interrupt a paragraph. */
- if(line->indent >= ctx->code_indent_offset &&
- (pivot_line->type == MD_LINE_BLANK || pivot_line->type == MD_LINE_INDENTEDCODE))
- {
+ if(line->indent >= ctx->code_indent_offset && (pivot_line->type != MD_LINE_TEXT)) {
line->type = MD_LINE_INDENTEDCODE;
- MD_ASSERT(line->indent >= ctx->code_indent_offset);
line->indent -= ctx->code_indent_offset;
line->data = 0;
break;
@@ -6063,7 +6060,9 @@ md_analyze_line(MD_CTX* ctx, OFF beg, OFF* p_end,
}
/* Check whether we are starting code fence. */
- if(off < ctx->size && ISANYOF2(off, _T('`'), _T('~'))) {
+ if(line->indent < ctx->code_indent_offset &&
+ off < ctx->size && ISANYOF2(off, _T('`'), _T('~')))
+ {
if(md_is_opening_code_fence(ctx, off, &off)) {
line->type = MD_LINE_FENCEDCODE;
line->data = 1;
diff --git a/test/coverage.txt b/test/coverage.txt
index de8862d..107d48d 100644
--- a/test/coverage.txt
+++ b/test/coverage.txt
@@ -339,6 +339,22 @@ bar
````````````````````````````````
+### [Issue 200](https://github.com/mity/md4c/issues/200)
+
+```````````````````````````````` example
+<!-- foo -->
+ ```
+ bar
+ ```
+.
+<!-- foo -->
+<pre><code>```
+bar
+```
+</code></pre>
+````````````````````````````````
+
+
## Code coverage
### `md_is_unicode_whitespace__()`