md_is_container_mark: Recognize list item marks just before EOF. We were recognizing the list item marks when a new line or a blank character follows. However, given end-of-file means implicitly also an end-of-line, we should recognize in that situation too. Fixes #139.
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 56 57 58 59 60 61 62 63 64 65 66 67 68
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3b465d4..efe693f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,9 @@ Fixes:
The tag `<tbody></tbody>` is suppressed whenever the table has zero body
rows.
+ * [#139](https://github.com/mity/md4c/issues/139):
+ Recognize a list item mark even when EOF follows it.
+
## Version 0.4.6
diff --git a/src/md4c.c b/src/md4c.c
index 314000e..f2af228 100644
--- a/src/md4c.c
+++ b/src/md4c.c
@@ -5611,11 +5611,11 @@ md_is_container_mark(MD_CTX* ctx, unsigned indent, OFF beg, OFF* p_end, MD_CONTA
OFF off = beg;
OFF max_end;
- if(indent >= ctx->code_indent_offset)
+ if(off >= ctx->size || indent >= ctx->code_indent_offset)
return FALSE;
/* Check for block quote mark. */
- if(off < ctx->size && CH(off) == _T('>')) {
+ if(CH(off) == _T('>')) {
off++;
p_container->ch = _T('>');
p_container->is_loose = FALSE;
@@ -5627,13 +5627,13 @@ md_is_container_mark(MD_CTX* ctx, unsigned indent, OFF beg, OFF* p_end, MD_CONTA
}
/* Check for list item bullet mark. */
- if(off+1 < ctx->size && ISANYOF(off, _T("-+*")) && (ISBLANK(off+1) || ISNEWLINE(off+1))) {
+ if(ISANYOF(off, _T("-+*")) && (off+1 >= ctx->size || ISBLANK(off+1) || ISNEWLINE(off+1))) {
p_container->ch = CH(off);
p_container->is_loose = FALSE;
p_container->is_task = FALSE;
p_container->mark_indent = indent;
p_container->contents_indent = indent + 1;
- *p_end = off + 1;
+ *p_end = off+1;
return TRUE;
}
@@ -5646,16 +5646,16 @@ md_is_container_mark(MD_CTX* ctx, unsigned indent, OFF beg, OFF* p_end, MD_CONTA
p_container->start = p_container->start * 10 + CH(off) - _T('0');
off++;
}
- if(off > beg && off+1 < ctx->size &&
+ if(off > beg &&
(CH(off) == _T('.') || CH(off) == _T(')')) &&
- (ISBLANK(off+1) || ISNEWLINE(off+1)))
+ (off+1 >= ctx->size || ISBLANK(off+1) || ISNEWLINE(off+1)))
{
p_container->ch = CH(off);
p_container->is_loose = FALSE;
p_container->is_task = FALSE;
p_container->mark_indent = indent;
p_container->contents_indent = indent + off - beg + 1;
- *p_end = off + 1;
+ *p_end = off+1;
return TRUE;
}