summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2016-02-06 22:05:27 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2016-02-06 22:05:27 -0800
commitf97750517aa62066c1feab178262b32e370f22ce (patch)
tree4b2deb86f5ad3f875a16b88d1b70080570aeed56
parent3d1229c9acb350a394a945561546eb448b19c7aa (diff)
Fixed handling of tabs in lists.
-rw-r--r--src/blocks.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/blocks.c b/src/blocks.c
index 1f4a008..acb9ab4 100644
--- a/src/blocks.c
+++ b/src/blocks.c
@@ -626,6 +626,9 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
cmark_chunk input;
bool maybe_lazy;
char c;
+ bool save_partially_consumed_tab;
+ int save_offset;
+ int save_column;
if (parser->options & CMARK_OPT_VALIDATE_UTF8) {
cmark_utf8proc_check(parser->curline, buffer, bytes);
@@ -861,21 +864,28 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
S_advance_offset(parser, &input,
parser->first_nonspace + matched - parser->offset,
false);
- i = 0;
- // TODO handle tabs
- while (i <= 5 && (c = peek_at(&input, parser->offset + i)) && c == ' ') {
- i++;
+
+ save_partially_consumed_tab = parser->partially_consumed_tab;
+ save_offset = parser->offset;
+ save_column = parser->column;
+
+ while (parser->column - save_column <= 5 &&
+ (c = peek_at(&input, parser->offset)) &&
+ (c == ' ' || c == '\t')) {
+ S_advance_offset(parser, &input, 1, true);
}
- // i = number of spaces after marker, up to 5
- if (i >= 5 || i < 1 ||
- S_is_line_end_char(peek_at(&input, parser->offset))) {
+
+ i = parser->column - save_column;
+ if (i >= 5 || i < 1) {
data->padding = matched + 1;
+ parser->offset = save_offset;
+ parser->column = save_column;
+ parser->partially_consumed_tab = save_partially_consumed_tab;
if (i > 0) {
- S_advance_offset(parser, &input, 1, false);
+ S_advance_offset(parser, &input, 1, true);
}
} else {
data->padding = matched + i;
- S_advance_offset(parser, &input, i, true);
}
// check container; if it's a list, see if this list item