summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/blocks.c7
-rw-r--r--src/parser.h1
2 files changed, 6 insertions, 2 deletions
diff --git a/src/blocks.c b/src/blocks.c
index 6d02a84..424257c 100644
--- a/src/blocks.c
+++ b/src/blocks.c
@@ -70,6 +70,7 @@ cmark_parser *cmark_parser_new(int options) {
parser->first_nonspace_column = 0;
parser->indent = 0;
parser->blank = false;
+ parser->partially_consumed_tab = false;
parser->curline = line;
parser->last_line_length = 0;
parser->linebuf = buf;
@@ -574,11 +575,13 @@ static void S_advance_offset(cmark_parser *parser, cmark_chunk *input,
while (count > 0 && (c = peek_at(input, parser->offset))) {
if (c == '\t') {
chars_to_tab = TAB_STOP - (parser->column % TAB_STOP);
- chars_to_advance = chars_to_tab > count ? count : chars_to_tab;
+ parser->partially_consumed_tab = chars_to_tab > count;
+ chars_to_advance = parser->partially_consumed_tab ? count : chars_to_tab;
parser->column += chars_to_advance;
- parser->offset += chars_to_advance < chars_to_tab ? 0 : 1;
+ parser->offset += parser->partially_consumed_tab ? 0 : 1;
count -= (columns ? chars_to_advance : 1);
} else {
+ parser->partially_consumed_tab = false;
parser->offset += 1;
parser->column += 1; // assume ascii; block starts are ascii
count -= 1;
diff --git a/src/parser.h b/src/parser.h
index f359e10..b3ff39b 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -22,6 +22,7 @@ struct cmark_parser {
bufsize_t first_nonspace_column;
int indent;
bool blank;
+ bool partially_consumed_tab;
cmark_strbuf *curline;
bufsize_t last_line_length;
cmark_strbuf *linebuf;