Branch Coverage

src/mds_block.c
Criterion Covered Total %
branch 1323 1770 74.7


line true false branch
122 4839 4533 if (need <= *cap) return;
123 15 4518 nc = *cap ? *cap : 256;
124 43 4533 while (nc < need) nc = nc + (nc >> 1) + 64;
142 3848 0 if (n) memcpy(b->bytepool + off, s, n);
147 2244 12700 if (b->ev_len == b->ev_cap) {
148 6 2238 size_t nc = b->ev_cap ? b->ev_cap * 2 : 64;
162 5534 0 e->u.enter.d = d ? *d : (mds_block_detail){0};
165 114 5420 if (t == MDS_BLK_CODE_FENCED && d && d->u.code_fenced.info_len) {
114 0 if (t == MDS_BLK_CODE_FENCED && d && d->u.code_fenced.info_len) {
19 95 if (t == MDS_BLK_CODE_FENCED && d && d->u.code_fenced.info_len) {
213 14944 2460 for (i = 0; i < n; i++) {
217 114 5420 if (e->u.enter.t == MDS_BLK_CODE_FENCED && e->u.enter.info_len) {
19 95 if (e->u.enter.t == MDS_BLK_CODE_FENCED && e->u.enter.info_len) {
222 5534 0 if (MDS_LIKELY(cb.enter_block != NULL))
226 5534 0 if (MDS_LIKELY(cb.leave_block != NULL))
230 512 0 if (MDS_LIKELY(cb.text != NULL))
234 200 0 if (MDS_LIKELY(cb.raw != NULL))
252 0 3604 if (b->depth >= MAX_DEPTH) return 0;
258 377 3227 if (k == CT_LIST) b->list_depth++;
305 3368 0 while (q < end && *q == ' ' && lead < 3) { q++; lead++; }
1 3367 while (q < end && *q == ' ' && lead < 3) { q++; lead++; }
1 0 while (q < end && *q == ' ' && lead < 3) { q++; lead++; }
306 3367 0 if (q >= end || *q != '[') return 0;
2659 708 if (q >= end || *q != '[') return 0;
311 3488 0 while (q < end && *q != ']') {
2828 660 while (q < end && *q != ']') {
312 21 2807 if (*q == '\\' && q + 1 < end) { q += 2; continue; }
21 0 if (*q == '\\' && q + 1 < end) { q += 2; continue; }
313 48 2759 if (*q == '[') return 0;
314 15 2744 if (*q == '\n') {
315 15 0 if (++label_nl > 0) {
318 15 0 while (r < end && (*r == ' ' || *r == '\t')) r++;
0 15 while (r < end && (*r == ' ' || *r == '\t')) r++;
0 15 while (r < end && (*r == ' ' || *r == '\t')) r++;
319 15 0 if (r >= end || *r == '\n') return 0;
0 15 if (r >= end || *r == '\n') return 0;
324 660 0 if (q >= end || *q != ']') return 0;
0 660 if (q >= end || *q != ']') return 0;
326 12 648 if (le == ls) return 0; /* empty label invalid */
329 651 25 for (r = ls; r < le; r++) {
330 632 19 if (*r != ' ' && *r != '\t' && *r != '\n') { has_nonws = 1; break; }
632 0 if (*r != ' ' && *r != '\t' && *r != '\n') { has_nonws = 1; break; }
623 9 if (*r != ' ' && *r != '\t' && *r != '\n') { has_nonws = 1; break; }
332 25 623 if (!has_nonws) return 0;
334 542 81 if (q >= end || *q != ':') return 0;
262 280 if (q >= end || *q != ':') return 0;
338 563 3 while (q < end && (*q == ' ' || *q == '\t' || *q == '\n')) {
277 286 while (q < end && (*q == ' ' || *q == '\t' || *q == '\n')) {
0 286 while (q < end && (*q == ' ' || *q == '\t' || *q == '\n')) {
9 277 while (q < end && (*q == ' ' || *q == '\t' || *q == '\n')) {
339 9 277 if (*q == '\n') { if (++nl > 1) return 0; }
0 9 if (*q == '\n') { if (++nl > 1) return 0; }
342 3 277 if (q >= end) return 0;
344 9 268 if (*q == '<') {
347 36 0 while (q < end && *q != '>' && *q != '\n' && *q != '<') q++;
27 9 while (q < end && *q != '>' && *q != '\n' && *q != '<') q++;
27 0 while (q < end && *q != '>' && *q != '\n' && *q != '<') q++;
27 0 while (q < end && *q != '>' && *q != '\n' && *q != '<') q++;
348 9 0 if (q >= end || *q != '>') return 0;
0 9 if (q >= end || *q != '>') return 0;
353 1543 132 while (q < end && *q != ' ' && *q != '\t' && *q != '\n') {
1437 106 while (q < end && *q != ' ' && *q != '\t' && *q != '\n') {
1437 0 while (q < end && *q != ' ' && *q != '\t' && *q != '\n') {
1407 30 while (q < end && *q != ' ' && *q != '\t' && *q != '\n') {
355 0 1407 if ((unsigned char)*q < 0x20) return 0;
359 0 268 if (ue == us) return 0;
367 311 135 while (q < end && (*q == ' ' || *q == '\t' || *q == '\n')) {
133 178 while (q < end && (*q == ' ' || *q == '\t' || *q == '\n')) {
0 178 while (q < end && (*q == ' ' || *q == '\t' || *q == '\n')) {
36 142 while (q < end && (*q == ' ' || *q == '\t' || *q == '\n')) {
368 36 133 if (*q == '\n') saw_nl++;
372 142 135 if (q < end && (*q == '"' || *q == '\'' || *q == '(') && saw_nl <= 1 && saw_ws) {
42 100 if (q < end && (*q == '"' || *q == '\'' || *q == '(') && saw_nl <= 1 && saw_ws) {
27 15 if (q < end && (*q == '"' || *q == '\'' || *q == '(') && saw_nl <= 1 && saw_ws) {
3 24 if (q < end && (*q == '"' || *q == '\'' || *q == '(') && saw_nl <= 1 && saw_ws) {
118 0 if (q < end && (*q == '"' || *q == '\'' || *q == '(') && saw_nl <= 1 && saw_ws) {
115 3 if (q < end && (*q == '"' || *q == '\'' || *q == '(') && saw_nl <= 1 && saw_ws) {
374 115 0 close = (open == '(') ? ')' : open;
380 890 3 while (q < end && *q != close) {
778 112 while (q < end && *q != close) {
381 778 0 if (open != '(' && *q == '\\' && q + 1 < end) { q += 2; continue; }
9 769 if (open != '(' && *q == '\\' && q + 1 < end) { q += 2; continue; }
9 0 if (open != '(' && *q == '\\' && q + 1 < end) { q += 2; continue; }
382 0 769 if (open == '(' && *q == '(') { /* unescaped '(' invalid in paren title */
0 0 if (open == '(' && *q == '(') { /* unescaped '(' invalid in paren title */
385 12 757 if (*q == '\n') {
387 12 0 while (r < end && (*r == ' ' || *r == '\t')) r++;
0 12 while (r < end && (*r == ' ' || *r == '\t')) r++;
0 12 while (r < end && (*r == ' ' || *r == '\t')) r++;
388 12 0 if (r >= end || *r == '\n') { blank_found = 1; break; }
0 12 if (r >= end || *r == '\n') { blank_found = 1; break; }
392 0 115 if (blank_found) { ts = NULL; te = NULL; q = save_after_url; goto end_title; }
393 112 3 if (q < end && *q == close) {
112 0 if (q < end && *q == close) {
398 24 100 while (check < end && check < end && *check != '\n') {
24 0 while (check < end && check < end && *check != '\n') {
18 6 while (check < end && check < end && *check != '\n') {
399 6 12 if (*check != ' ' && *check != '\t') { ts = NULL; te = NULL; q = save_after_url; goto end_title; }
6 0 if (*check != ' ' && *check != '\t') { ts = NULL; te = NULL; q = save_after_url; goto end_title; }
411 54 235 while (q < end && (*q == ' ' || *q == '\t')) q++;
12 42 while (q < end && (*q == ' ' || *q == '\t')) q++;
0 42 while (q < end && (*q == ' ' || *q == '\t')) q++;
412 42 235 if (q < end && *q == '\n') q++;
33 9 if (q < end && *q == '\n') q++;
413 9 235 else if (q < end) {
415 0 9 if (ts) {
418 0 0 while (q < end && (*q == ' ' || *q == '\t')) q++;
0 0 while (q < end && (*q == ' ' || *q == '\t')) q++;
0 0 while (q < end && (*q == ' ' || *q == '\t')) q++;
419 0 0 if (q < end && *q == '\n') q++;
0 0 if (q < end && *q == '\n') q++;
420 0 0 else if (q < end) return 0;
433 21 241 if (ctx->refs) return;
440 12 9 if (ctx->footnotes) return;
490 2 456 if (!ilen) return;
502 1649 456 while (p < end) {
504 41 1608 if (!le) le = end;
505 1608 41 nxt = (le < end) ? le + 1 : end;
511 1312 433 while (q < le && *q == ' ' && ind < 3) { q++; ind++; }
114 1198 while (q < le && *q == ' ' && ind < 3) { q++; ind++; }
96 18 while (q < le && *q == ' ' && ind < 3) { q++; ind++; }
513 10 1639 if (in_fence) {
516 20 5 while (q + run < le && q[run] == fence_ch) run++;
15 5 while (q + run < le && q[run] == fence_ch) run++;
517 5 5 if (run >= fence_len) {
519 0 5 while (tail < le && (*tail == ' ' || *tail == '\t')) tail++;
0 0 while (tail < le && (*tail == ' ' || *tail == '\t')) tail++;
0 0 while (tail < le && (*tail == ' ' || *tail == '\t')) tail++;
520 5 0 if (tail == le) in_fence = 0;
528 1200 439 if (le - q >= 3 && (q[0] == '`' || q[0] == '~') && q[1] == q[0] && q[2] == q[0]) {
1194 6 if (le - q >= 3 && (q[0] == '`' || q[0] == '~') && q[1] == q[0] && q[2] == q[0]) {
12 1182 if (le - q >= 3 && (q[0] == '`' || q[0] == '~') && q[1] == q[0] && q[2] == q[0]) {
14 4 if (le - q >= 3 && (q[0] == '`' || q[0] == '~') && q[1] == q[0] && q[2] == q[0]) {
5 9 if (le - q >= 3 && (q[0] == '`' || q[0] == '~') && q[1] == q[0] && q[2] == q[0]) {
531 1 4 while (q + fl < le && q[fl] == fc) fl++;
0 1 while (q + fl < le && q[fl] == fc) fl++;
545 1160 474 if (le - q >= 4 && q[0] == '[' && q[1] == '^') {
40 1120 if (le - q >= 4 && q[0] == '[' && q[1] == '^') {
21 19 if (le - q >= 4 && q[0] == '[' && q[1] == '^') {
548 249 0 while (lbe < le && *lbe != ']' && *lbe != '[' && *lbe != '\n') lbe++;
228 21 while (lbe < le && *lbe != ']' && *lbe != '[' && *lbe != '\n') lbe++;
228 0 while (lbe < le && *lbe != ']' && *lbe != '[' && *lbe != '\n') lbe++;
228 0 while (lbe < le && *lbe != ']' && *lbe != '[' && *lbe != '\n') lbe++;
549 21 0 if (lbe < le && *lbe == ']' && lbe > lbs &&
21 0 if (lbe < le && *lbe == ']' && lbe > lbs &&
21 0 if (lbe < le && *lbe == ']' && lbe > lbs &&
550 21 0 lbe + 1 < le && lbe[1] == ':') {
21 0 lbe + 1 < le && lbe[1] == ':') {
553 48 6 while (bs < le && (*bs == ' ' || *bs == '\t')) bs++;
33 15 while (bs < le && (*bs == ' ' || *bs == '\t')) bs++;
0 15 while (bs < le && (*bs == ' ' || *bs == '\t')) bs++;
559 15 6 if (bs < le) {
566 42 9 while (p < end) {
568 0 42 if (!le2) le2 = end;
569 42 0 nxt2 = (le2 < end) ? le2 + 1 : end;
573 96 18 for (r = p; r < le2; r++) {
574 24 72 if (*r != ' ' && *r != '\t') { blank = 0; break; }
24 0 if (*r != ' ' && *r != '\t') { blank = 0; break; }
576 18 24 if (blank) {
585 72 0 while (r < le2 && sp < 4) {
60 12 while (r < le2 && sp < 4) {
586 48 12 if (*r == ' ') { sp++; r++; }
587 0 12 else if (*r == '\t') { sp = 4; r++; break; }
590 12 12 if (sp < 4) break; /* end of def body */
593 12 0 if (le2 > r) {
601 33 0 while (blen > 0 && (body[blen-1] == '\n' ||
12 21 while (blen > 0 && (body[blen-1] == '\n' ||
602 0 21 body[blen-1] == ' ' ||
603 0 21 body[blen-1] == '\t')) blen--;
646 910 0 while (q < end && *q == ' ' && lead < 3) { q++; lead++; }
1 909 while (q < end && *q == ' ' && lead < 3) { q++; lead++; }
1 0 while (q < end && *q == ' ' && lead < 3) { q++; lead++; }
647 31 878 if (end - q < 4) return 0;
648 79 799 if (q[0] != '[' || q[1] != '^') return 0;
79 0 if (q[0] != '[' || q[1] != '^') return 0;
651 0 0 while (q < end && *q != ']' && *q != '\n' && *q != '[') q++;
0 0 while (q < end && *q != ']' && *q != '\n' && *q != '[') q++;
0 0 while (q < end && *q != ']' && *q != '\n' && *q != '[') q++;
0 0 while (q < end && *q != ']' && *q != '\n' && *q != '[') q++;
652 0 0 if (q >= end || *q != ']' || q == ls) return 0;
0 0 if (q >= end || *q != ']' || q == ls) return 0;
0 0 if (q >= end || *q != ']' || q == ls) return 0;
655 0 0 if (q >= end || *q != ':') return 0;
0 0 if (q >= end || *q != ':') return 0;
658 0 0 while (q < end && (*q == ' ' || *q == '\t')) q++;
0 0 while (q < end && (*q == ' ' || *q == '\t')) q++;
0 0 while (q < end && (*q == ' ' || *q == '\t')) q++;
664 0 0 while (q < end) {
665 0 0 if (*q == '\n') {
670 0 0 while (r < end && *r == ' ' && rlead < 3) { r++; rlead++; }
0 0 while (r < end && *r == ' ' && rlead < 3) { r++; rlead++; }
0 0 while (r < end && *r == ' ' && rlead < 3) { r++; rlead++; }
671 0 0 if (end - r >= 4 && r[0] == '[' && r[1] == '^') {
0 0 if (end - r >= 4 && r[0] == '[' && r[1] == '^') {
0 0 if (end - r >= 4 && r[0] == '[' && r[1] == '^') {
673 0 0 while (rr < end && *rr != ']' && *rr != '\n' && *rr != '[') rr++;
0 0 while (rr < end && *rr != ']' && *rr != '\n' && *rr != '[') rr++;
0 0 while (rr < end && *rr != ']' && *rr != '\n' && *rr != '[') rr++;
0 0 while (rr < end && *rr != ']' && *rr != '\n' && *rr != '[') rr++;
674 0 0 if (rr < end && *rr == ']' && rr + 1 < end && rr[1] == ':') {
0 0 if (rr < end && *rr == ']' && rr + 1 < end && rr[1] == ':') {
0 0 if (rr < end && *rr == ']' && rr + 1 < end && rr[1] == ':') {
0 0 if (rr < end && *rr == ']' && rr + 1 < end && rr[1] == ':') {
713 799 0 while (p < end) {
715 267 532 if (!q) return NULL;
718 338 225 while (bs > p && bs[-1] == '\\') bs--;
31 307 while (bs > p && bs[-1] == '\\') bs--;
719 501 31 if (((q - bs) & 1u) == 0u) return q; /* even ⇒ unescaped */
750 243 0 while (p < end && (*p == ' ' || *p == '\t')) p++;
0 243 while (p < end && (*p == ' ' || *p == '\t')) p++;
0 243 while (p < end && (*p == ' ' || *p == '\t')) p++;
751 246 0 while (end > p && (end[-1] == ' ' || end[-1] == '\t')) end--;
3 243 while (end > p && (end[-1] == ' ' || end[-1] == '\t')) end--;
0 243 while (end > p && (end[-1] == ' ' || end[-1] == '\t')) end--;
753 243 0 if (p < end && *p == '|') p++;
222 21 if (p < end && *p == '|') p++;
755 243 0 if (end > p && end[-1] == '|') {
210 33 if (end > p && end[-1] == '|') {
758 210 0 while (q > p && q[-1] == '\\') { esc = !esc; q--; }
0 210 while (q > p && q[-1] == '\\') { esc = !esc; q--; }
759 210 0 if (!esc) end--;
762 501 0 while (p <= end) {
764 258 243 cell_end = pipe ? pipe : end;
767 947 9 while (cs < ce && (*cs == ' ' || *cs == '\t')) cs++;
455 492 while (cs < ce && (*cs == ' ' || *cs == '\t')) cs++;
0 492 while (cs < ce && (*cs == ' ' || *cs == '\t')) cs++;
768 933 9 while (ce > cs && (ce[-1] == ' ' || ce[-1] == '\t')) ce--;
441 492 while (ce > cs && (ce[-1] == ' ' || ce[-1] == '\t')) ce--;
0 492 while (ce > cs && (ce[-1] == ' ' || ce[-1] == '\t')) ce--;
769 501 0 if (count < max_cells) {
774 243 258 if (!pipe) break;
795 147 0 while (p < end && (*p == ' ' || *p == '\t')) p++;
0 147 while (p < end && (*p == ' ' || *p == '\t')) p++;
0 147 while (p < end && (*p == ' ' || *p == '\t')) p++;
796 147 0 while (end > p && (end[-1] == ' ' || end[-1] == '\t')) end--;
0 147 while (end > p && (end[-1] == ' ' || end[-1] == '\t')) end--;
0 147 while (end > p && (end[-1] == ' ' || end[-1] == '\t')) end--;
797 0 147 if (p >= end) return 0;
798 129 18 if (*p == '|') p++;
800 147 0 if (end > p && end[-1] == '|') end--;
129 18 if (end > p && end[-1] == '|') end--;
802 296 0 while (p <= end) {
804 1745 139 while (p < end && *p != '|') p++;
1588 157 while (p < end && *p != '|') p++;
807 504 0 while (cs < ce && (*cs == ' ' || *cs == '\t')) cs++;
208 296 while (cs < ce && (*cs == ' ' || *cs == '\t')) cs++;
0 296 while (cs < ce && (*cs == ' ' || *cs == '\t')) cs++;
808 498 0 while (ce > cs && (ce[-1] == ' ' || ce[-1] == '\t')) ce--;
202 296 while (ce > cs && (ce[-1] == ' ' || ce[-1] == '\t')) ce--;
0 296 while (ce > cs && (ce[-1] == ' ' || ce[-1] == '\t')) ce--;
809 0 296 if (cs >= ce) return 0;
811 28 268 if (left) cs++;
812 296 0 right = (ce > cs && ce[-1] == ':');
28 268 right = (ce > cs && ce[-1] == ':');
813 28 268 if (right) ce--;
814 0 296 if (cs >= ce) return 0;
815 1062 288 for (q = cs; q < ce; q++)
816 8 1054 if (*q != '-') return 0;
817 288 0 if (count < max_cells) {
818 28 260 aligns[count] = left && right ? MDS_ALIGN_CENTER :
14 14 aligns[count] = left && right ? MDS_ALIGN_CENTER :
260 14 aligns[count] = left && right ? MDS_ALIGN_CENTER :
14 246 aligns[count] = left && right ? MDS_ALIGN_CENTER :
823 139 149 if (p >= end) break;
833 327 931 const char* le = nl ? nl : end;
834 1258 0 if (le > p && le[-1] == '\r') le--;
0 1258 if (le > p && le[-1] == '\r') le--;
836 327 931 return nl ? nl + 1 : end;
846 0 273 if (n == 0) return 1;
847 1085 243 for (i = 0; i < n; i++) {
849 1080 5 if (c == '*' || c == '_' || c == '~' || c == '`' ||
1068 12 if (c == '*' || c == '_' || c == '~' || c == '`' ||
1067 1 if (c == '*' || c == '_' || c == '~' || c == '`' ||
1067 0 if (c == '*' || c == '_' || c == '~' || c == '`' ||
1061 6 if (c == '*' || c == '_' || c == '~' || c == '`' ||
850 1061 0 c == '[' || c == ']' || c == '!' || c == '<' ||
1061 0 c == '[' || c == ']' || c == '!' || c == '<' ||
1055 6 c == '[' || c == ']' || c == '!' || c == '<' ||
1055 0 c == '[' || c == ']' || c == '!' || c == '<' ||
851 1055 0 c == '&' || c == '\\' || c == '\n')
0 1055 c == '&' || c == '\\' || c == '\n')
855 98 145 if (n >= 2 && s[n-1] == ' ' && s[n-2] == ' ') return 0;
0 98 if (n >= 2 && s[n-1] == ' ' && s[n-2] == ' ') return 0;
0 0 if (n >= 2 && s[n-1] == ' ' && s[n-2] == ' ') return 0;
880 350 164 for (i = 0; i < nhead; i++) {
883 329 21 if (i < count && cn[i]) {
320 9 if (i < count && cn[i]) {
886 273 47 if (MDS_LIKELY(!tbl_cell_needs_unescape(s, n))) {
893 243 30 if (MDS_LIKELY(tbl_cell_is_plain(s, n))) {
905 424 47 for (j = 0; j < n; j++) {
906 83 341 if (s[j] == '\\' && j + 1 < n && s[j+1] == '|') {
77 6 if (s[j] == '\\' && j + 1 < n && s[j+1] == '|') {
29 48 if (s[j] == '\\' && j + 1 < n && s[j+1] == '|') {
950 844 103 if (p2 >= end) return 0;
951 24 79 if (!tbl_find_pipe(p, le1)) return 0;
953 79 0 if (nhead < 1 || nhead > MDS_TBL_MAX_COLS) return 0;
0 79 if (nhead < 1 || nhead > MDS_TBL_MAX_COLS) return 0;
983 0 68 if (p2 >= end) return 0; /* need a second line */
985 0 68 if (!tbl_find_pipe(p, le1)) return 0;
988 68 0 if (nhead < 1 || nhead > MDS_TBL_MAX_COLS) return 0;
0 68 if (nhead < 1 || nhead > MDS_TBL_MAX_COLS) return 0;
992 0 68 if (nsep != nhead) return 0;
1010 96 68 while (row < end) {
1012 0 96 if (le == row) { row = nx; break; } /* blank */
1013 0 96 if (!tbl_find_pipe(row, le)) break;
1014 56 40 if (!body_open) {
1022 56 12 if (body_open) sax_leave(b, MDS_BLK_TABLE_BODY);
1054 3285 238 while (p < end) {
1057 909 2376 if ((_bf & MDS_FLAG_FOOTNOTES)) {
1058 0 909 if (parse_footnote_def(p, end, &np, &fls, &fle, &bs, &be)) {
1061 0 0 while (blen > 0 && (bs[blen - 1] == '\n' || bs[blen - 1] == ' ' ||
0 0 while (blen > 0 && (bs[blen - 1] == '\n' || bs[blen - 1] == ' ' ||
0 0 while (blen > 0 && (bs[blen - 1] == '\n' || bs[blen - 1] == ' ' ||
1062 0 0 bs[blen - 1] == '\t')) blen--;
1076 106 156 ts ? ts : "", ts ? (size_t)(te - ts) : 0);
106 156 ts ? ts : "", ts ? (size_t)(te - ts) : 0);
1083 244 3017 if (p > b->para) {
1085 12 232 if (rem) memmove(b->para, p, rem);
1089 3053 238 while (b->para_len > 0) {
1091 3026 27 if (c == ' ' || c == '\t' || c == '\n' || c == '\r') b->para_len--;
3023 3 if (c == ' ' || c == '\t' || c == '\n' || c == '\r') b->para_len--;
3023 0 if (c == ' ' || c == '\t' || c == '\n' || c == '\r') b->para_len--;
0 3023 if (c == ' ' || c == '\t' || c == '\n' || c == '\r') b->para_len--;
1096 3024 238 while (lead < b->para_len &&
1097 1 3023 (b->para[lead] == ' ' || b->para[lead] == '\t' || b->para[lead] == '\n'))
0 3023 (b->para[lead] == ' ' || b->para[lead] == '\t' || b->para[lead] == '\n'))
0 3023 (b->para[lead] == ' ' || b->para[lead] == '\t' || b->para[lead] == '\n'))
1099 1 3260 if (lead) { memmove(b->para, b->para + lead, b->para_len - lead); b->para_len -= lead; }
1100 238 3023 if (b->para_len == 0) {
1107 78 2945 if (sx) {
1112 913 2032 } else if ((b->ctx->flags & MDS_FLAG_TABLES) &&
1113 912 1 b->para_len >= 3) {
1119 947 912 while (tp < tend) {
1122 68 879 if (tbl_peek_header(tp, tend)) {
1124 3 65 if (tp > run) {
1126 6 0 while (re > run && (re[-1] == '\n' || re[-1] == '\r' ||
3 3 while (re > run && (re[-1] == '\n' || re[-1] == '\r' ||
0 3 while (re > run && (re[-1] == '\n' || re[-1] == '\r' ||
1127 0 3 re[-1] == ' ' || re[-1] == '\t')) re--;
0 3 re[-1] == ' ' || re[-1] == '\t')) re--;
1128 3 0 if (re > run) {
1142 844 68 if (run < tend) {
1144 844 0 while (re > run && (re[-1] == '\n' || re[-1] == '\r' ||
0 844 while (re > run && (re[-1] == '\n' || re[-1] == '\r' ||
0 844 while (re > run && (re[-1] == '\n' || re[-1] == '\r' ||
1145 0 844 re[-1] == ' ' || re[-1] == '\t')) re--;
0 844 re[-1] == ' ' || re[-1] == '\t')) re--;
1146 844 0 if (re > run) {
1167 173 0 while (b->code_len > 0) {
1171 173 0 if (ls > 0) ls--; /* skip its '\n' */
1172 1455 130 while (ls > 0 && b->code_body[ls - 1] != '\n') ls--;
1412 43 while (ls > 0 && b->code_body[ls - 1] != '\n') ls--;
1174 218 3 for (j = ls; j + 1 < i; j++) {
1175 170 48 if (b->code_body[j] != ' ' && b->code_body[j] != '\t') { blank = 0; break; }
170 0 if (b->code_body[j] != ' ' && b->code_body[j] != '\t') { blank = 0; break; }
1177 170 3 if (!blank) break;
1182 170 0 if (b->code_len) sax_text(b, b->code_body, b->code_len);
1194 99 15 if (b->code_len) sax_text(b, b->code_body, b->code_len);
1208 200 0 while (b->html_len > 0) {
1211 200 0 if (ls > 0) ls--;
1212 2562 104 while (ls > 0 && b->html_body[ls - 1] != '\n') ls--;
2466 96 while (ls > 0 && b->html_body[ls - 1] != '\n') ls--;
1214 260 0 for (j = ls; j + 1 < i; j++) {
1215 200 60 if (b->html_body[j] != ' ' && b->html_body[j] != '\t') { blank = 0; break; }
200 0 if (b->html_body[j] != ' ' && b->html_body[j] != '\t') { blank = 0; break; }
1217 200 0 if (!blank) break;
1222 200 0 if (b->html_len) sax_raw(b, b->html_body, b->html_len);
1244 0 1144 if (c->opened) return;
1247 176 968 if (c->kind == CT_QUOTE) {
1249 377 591 } else if (c->kind == CT_LIST) {
1255 591 0 } else if (c->kind == CT_LIST_ITEM) {
1261 0 1144 if (!c->opened) return;
1262 176 968 if (c->kind == CT_QUOTE) {
1264 377 591 } else if (c->kind == CT_LIST) {
1266 377 0 if (c->ev_idx >= 0 && (size_t)c->ev_idx < b->ev_len) {
377 0 if (c->ev_idx >= 0 && (size_t)c->ev_idx < b->ev_len) {
1268 377 0 if (e->type == EV_ENTER_BLOCK && e->u.enter.t == MDS_BLK_LIST) {
377 0 if (e->type == EV_ENTER_BLOCK && e->u.enter.t == MDS_BLK_LIST) {
1275 591 0 } else if (c->kind == CT_LIST_ITEM) {
1282 1091 7245 while (b->depth > target_depth) {
1297 904 6495 if (!nl) { *line_end_out = end; return end; }
1299 5373 1122 if (le > p && *(le - 1) == '\r') le--;
0 5373 if (le > p && *(le - 1) == '\r') le--;
1307 2330 9 while (q < end && col < max) {
1807 523 while (q < end && col < max) {
1308 1807 0 if (*q == ' ') { col++; q++; }
1309 0 0 else if (*q == '\t') {
1311 0 0 if (col + adv > max) break;
1321 12456 301 while (p < end) {
1322 3283 9173 if (*p == ' ') col++;
1323 0 9173 else if (*p == '\t') col += 4 - (col & 3);
1331 15651 1188 while (p < end) {
1332 11039 4612 if (*p != ' ' && *p != '\t') return 0;
11039 0 if (*p != ' ' && *p != '\t') return 0;
1343 2813 154 for (i = 0; i < n; i++) {
1345 2609 204 if (x >= 'A' && x <= 'Z') x = (char)(x + 32);
126 2483 if (x >= 'A' && x <= 'Z') x = (char)(x + 32);
1346 2813 0 if (y >= 'A' && y <= 'Z') y = (char)(y + 32);
0 2813 if (y >= 'A' && y <= 'Z') y = (char)(y + 32);
1347 2009 804 if (x != y) return 0;
1366 12623 146 for (i = 0; HTML6_TAGS[i]; i++) {
1368 1157 11466 if (tl == n && ascii_ieq(s, HTML6_TAGS[i], n)) return 1;
109 1048 if (tl == n && ascii_ieq(s, HTML6_TAGS[i], n)) return 1;
1374 1278 470 return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
1215 63 return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
1209 476 return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
1209 0 return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
1377 455 1096 return is_alpha(c) || (c >= '0' && c <= '9');
286 169 return is_alpha(c) || (c >= '0' && c <= '9');
6 280 return is_alpha(c) || (c >= '0' && c <= '9');
1392 134 0 if (p >= end || !is_alpha(*p)) return 0;
15 119 if (p >= end || !is_alpha(*p)) return 0;
1395 369 0 while (p < end && (is_alnum(*p) || *p == '-')) p++;
244 125 while (p < end && (is_alnum(*p) || *p == '-')) p++;
6 119 while (p < end && (is_alnum(*p) || *p == '-')) p++;
1400 476 119 for (i = 0; banned[i]; i++) {
1402 46 430 if (bl == nlen && ascii_ieq(name, banned[i], nlen)) return 0;
0 46 if (bl == nlen && ascii_ieq(name, banned[i], nlen)) return 0;
1406 146 3 while (p < end) {
1409 194 0 while (p < end && (*p == ' ' || *p == '\t')) p++;
48 146 while (p < end && (*p == ' ' || *p == '\t')) p++;
0 146 while (p < end && (*p == ' ' || *p == '\t')) p++;
1410 101 45 if (p == aws) break; /* must have ws before attr */
1411 45 0 if (p >= end || *p == '/' || *p == '>') break;
42 3 if (p >= end || *p == '/' || *p == '>') break;
42 0 if (p >= end || *p == '/' || *p == '>') break;
1412 0 42 if (!is_alpha(*p) && *p != '_' && *p != ':') return 0;
0 0 if (!is_alpha(*p) && *p != '_' && *p != ':') return 0;
0 0 if (!is_alpha(*p) && *p != '_' && *p != ':') return 0;
1414 159 0 while (p < end && (is_alnum(*p) || *p == '_' || *p == ':' || *p == '.' || *p == '-')) p++;
117 42 while (p < end && (is_alnum(*p) || *p == '_' || *p == ':' || *p == '.' || *p == '-')) p++;
0 42 while (p < end && (is_alnum(*p) || *p == '_' || *p == ':' || *p == '.' || *p == '-')) p++;
0 42 while (p < end && (is_alnum(*p) || *p == '_' || *p == ':' || *p == '.' || *p == '-')) p++;
0 42 while (p < end && (is_alnum(*p) || *p == '_' || *p == ':' || *p == '.' || *p == '-')) p++;
0 42 while (p < end && (is_alnum(*p) || *p == '_' || *p == ':' || *p == '.' || *p == '-')) p++;
1417 45 0 while (p < end && (*p == ' ' || *p == '\t')) p++;
3 42 while (p < end && (*p == ' ' || *p == '\t')) p++;
0 42 while (p < end && (*p == ' ' || *p == '\t')) p++;
1418 42 0 if (p < end && *p == '=') {
39 3 if (p < end && *p == '=') {
1420 42 0 while (p < end && (*p == ' ' || *p == '\t')) p++;
3 39 while (p < end && (*p == ' ' || *p == '\t')) p++;
0 39 while (p < end && (*p == ' ' || *p == '\t')) p++;
1421 0 39 if (p >= end) return 0;
1422 6 33 if (*p == '"' || *p == '\'') {
6 0 if (*p == '"' || *p == '\'') {
1424 276 12 while (p < end && *p != q) p++;
249 27 while (p < end && *p != q) p++;
1425 12 27 if (p >= end) return 0;
1429 0 0 while (p < end && *p != ' ' && *p != '\t' && *p != '\"'
0 0 while (p < end && *p != ' ' && *p != '\t' && *p != '\"'
0 0 while (p < end && *p != ' ' && *p != '\t' && *p != '\"'
1430 0 0 && *p != '\'' && *p != '=' && *p != '<' && *p != '>'
0 0 && *p != '\'' && *p != '=' && *p != '<' && *p != '>'
0 0 && *p != '\'' && *p != '=' && *p != '<' && *p != '>'
0 0 && *p != '\'' && *p != '=' && *p != '<' && *p != '>'
1431 0 0 && *p != '`') p++;
0 0 && *p != '`') p++;
1432 0 0 if (p == uv) return 0;
1438 104 3 while (p < end && (*p == ' ' || *p == '\t')) p++;
0 104 while (p < end && (*p == ' ' || *p == '\t')) p++;
0 104 while (p < end && (*p == ' ' || *p == '\t')) p++;
1439 104 3 if (p < end && *p == '/') p++;
6 98 if (p < end && *p == '/') p++;
1440 104 3 if (p >= end || *p != '>') return 0;
66 38 if (p >= end || *p != '>') return 0;
1442 17 21 while (p < end && (*p == ' ' || *p == '\t')) p++;
0 17 while (p < end && (*p == ' ' || *p == '\t')) p++;
0 17 while (p < end && (*p == ' ' || *p == '\t')) p++;
1451 12 0 if (p >= end || !is_alpha(*p)) return 0;
0 12 if (p >= end || !is_alpha(*p)) return 0;
1454 24 0 while (p < end && (is_alnum(*p) || *p == '-')) p++;
12 12 while (p < end && (is_alnum(*p) || *p == '-')) p++;
0 12 while (p < end && (is_alnum(*p) || *p == '-')) p++;
1458 48 12 for (i = 0; banned[i]; i++) {
1460 6 42 if (bl == nlen && ascii_ieq(name, banned[i], nlen)) return 0;
0 6 if (bl == nlen && ascii_ieq(name, banned[i], nlen)) return 0;
1463 15 0 while (p < end && (*p == ' ' || *p == '\t')) p++;
3 12 while (p < end && (*p == ' ' || *p == '\t')) p++;
0 12 while (p < end && (*p == ' ' || *p == '\t')) p++;
1464 12 0 if (p >= end || *p != '>') return 0;
3 9 if (p >= end || *p != '>') return 0;
1466 3 6 while (p < end && (*p == ' ' || *p == '\t')) p++;
0 3 while (p < end && (*p == ' ' || *p == '\t')) p++;
0 3 while (p < end && (*p == ' ' || *p == '\t')) p++;
1478 5120 9 while (p < end && *p == ' ' && lead < 3) { p++; lead++; }
501 4619 while (p < end && *p == ' ' && lead < 3) { p++; lead++; }
452 49 while (p < end && *p == ' ' && lead < 3) { p++; lead++; }
1479 4668 9 if (p >= end || *p != '<') return 0;
4334 334 if (p >= end || *p != '<') return 0;
1482 331 3 if (q + 2 < end && q[0] == '!' && q[1] == '-' && q[2] == '-') return 2;
43 288 if (q + 2 < end && q[0] == '!' && q[1] == '-' && q[2] == '-') return 2;
34 9 if (q + 2 < end && q[0] == '!' && q[1] == '-' && q[2] == '-') return 2;
31 3 if (q + 2 < end && q[0] == '!' && q[1] == '-' && q[2] == '-') return 2;
1484 303 0 if (q < end && *q == '?') return 3;
3 300 if (q < end && *q == '?') return 3;
1486 198 102 if (q + 7 < end && q[0] == '!' && q[1] == '[' && memcmp(q+2,"CDATA[",6) == 0) return 5;
12 186 if (q + 7 < end && q[0] == '!' && q[1] == '[' && memcmp(q+2,"CDATA[",6) == 0) return 5;
3 9 if (q + 7 < end && q[0] == '!' && q[1] == '[' && memcmp(q+2,"CDATA[",6) == 0) return 5;
3 0 if (q + 7 < end && q[0] == '!' && q[1] == '[' && memcmp(q+2,"CDATA[",6) == 0) return 5;
1488 294 3 if (q + 1 < end && *q == '!' && is_alpha(q[1])) return 4;
9 285 if (q + 1 < end && *q == '!' && is_alpha(q[1])) return 4;
3 6 if (q + 1 < end && *q == '!' && is_alpha(q[1])) return 4;
1494 1134 270 for (i = 0; t1[i]; i++) {
1496 906 228 if ((size_t)(end - q) >= tl && ascii_ieq(q, t1[i], tl)) {
24 882 if ((size_t)(end - q) >= tl && ascii_ieq(q, t1[i], tl)) {
1498 18 6 if (a == end || *a == ' ' || *a == '\t' || *a == '>') return 1;
12 6 if (a == end || *a == ' ' || *a == '\t' || *a == '>') return 1;
12 0 if (a == end || *a == ' ' || *a == '\t' || *a == '>') return 1;
12 0 if (a == end || *a == ' ' || *a == '\t' || *a == '>') return 1;
1508 270 0 if (r < end && *r == '/') { closing = 1; r++; }
39 231 if (r < end && *r == '/') { closing = 1; r++; }
1510 999 0 while (r < end && is_alnum(*r)) r++;
729 270 while (r < end && is_alnum(*r)) r++;
1512 255 15 if (nlen > 0 && is_html6_tag(name, nlen)) {
109 146 if (nlen > 0 && is_html6_tag(name, nlen)) {
1513 109 0 if (r == end || *r == ' ' || *r == '\t' || *r == '>'
90 19 if (r == end || *r == ' ' || *r == '\t' || *r == '>'
90 0 if (r == end || *r == ' ' || *r == '\t' || *r == '>'
0 90 if (r == end || *r == ' ' || *r == '\t' || *r == '>'
1514 0 0 || (!closing && r + 1 <= end && *r == '/' && r + 1 < end && r[1] == '>'))
0 0 || (!closing && r + 1 <= end && *r == '/' && r + 1 < end && r[1] == '>'))
0 0 || (!closing && r + 1 <= end && *r == '/' && r + 1 < end && r[1] == '>'))
0 0 || (!closing && r + 1 <= end && *r == '/' && r + 1 < end && r[1] == '>'))
0 0 || (!closing && r + 1 <= end && *r == '/' && r + 1 < end && r[1] == '>'))
1520 146 15 if (allow_type7) {
1522 146 0 if (r < end && *r == '/') {
12 134 if (r < end && *r == '/') {
1523 6 6 if (is_type7_close_tag(r + 1, end)) return 7;
1525 21 113 if (is_type7_open_tag(r, end)) return 7;
1534 36 428 if (blank) {
1535 36 0 return (type == 6 || type == 7);
0 36 return (type == 6 || type == 7);
1540 1115 57 for (q = p; q < end; q++) {
1541 1064 51 if (*q != '<') continue;
1542 51 0 if (q + 1 >= end || q[1] != '/') continue;
27 24 if (q + 1 >= end || q[1] != '/') continue;
1547 57 3 for (i = 0; t1[i]; i++) {
1549 48 9 if ((size_t)(end - r) >= tl + 1
1550 21 27 && ascii_ieq(r, t1[i], tl) && r[tl] == '>') return 1;
21 0 && ascii_ieq(r, t1[i], tl) && r[tl] == '>') return 1;
1557 830 12 for (q = p; q + 2 < end; q++)
1558 96 734 if (q[0] == '-' && q[1] == '-' && q[2] == '>') return 1;
68 28 if (q[0] == '-' && q[1] == '-' && q[2] == '>') return 1;
31 37 if (q[0] == '-' && q[1] == '-' && q[2] == '>') return 1;
1561 45 6 for (q = p; q + 1 < end; q++)
1562 6 39 if (q[0] == '?' && q[1] == '>') return 1;
3 3 if (q[0] == '?' && q[1] == '>') return 1;
1565 3 42 for (q = p; q < end; q++) if (*q == '>') return 1;
45 0 for (q = p; q < end; q++) if (*q == '>') return 1;
1568 252 27 for (q = p; q + 2 < end; q++)
1569 3 249 if (q[0] == ']' && q[1] == ']' && q[2] == '>') return 1;
3 0 if (q[0] == ']' && q[1] == ']' && q[2] == '>') return 1;
3 0 if (q[0] == ']' && q[1] == ']' && q[2] == '>') return 1;
1584 10387 18 while (p < end && *p == ' ' && lead < 3) { p++; lead++; }
1075 9312 while (p < end && *p == ' ' && lead < 3) { p++; lead++; }
968 107 while (p < end && *p == ' ' && lead < 3) { p++; lead++; }
1585 18 9419 if (p >= end) return 0;
1587 8700 719 if (c != '-' && c != '_' && c != '*') return 0;
8386 314 if (c != '-' && c != '_' && c != '*') return 0;
7727 659 if (c != '-' && c != '_' && c != '*') return 0;
1588 5524 307 while (p < end) {
1589 3094 2430 if (*p == c) count++;
1590 1385 1045 else if (*p != ' ' && *p != '\t') return 0;
1385 0 else if (*p != ' ' && *p != '\t') return 0;
1604 4893 9 while (p < end && *p == ' ' && lead < 3) { p++; lead++; }
474 4419 while (p < end && *p == ' ' && lead < 3) { p++; lead++; }
425 49 while (p < end && *p == ' ' && lead < 3) { p++; lead++; }
1605 4781 12 while (p < end && *p == '#' && n < 7) { p++; n++; }
316 4465 while (p < end && *p == '#' && n < 7) { p++; n++; }
316 0 while (p < end && *p == '#' && n < 7) { p++; n++; }
1606 149 4328 if (n == 0 || n > 6) return 0;
4 145 if (n == 0 || n > 6) return 0;
1607 142 3 if (p < end && *p != ' ' && *p != '\t') return 0;
10 132 if (p < end && *p != ' ' && *p != '\t') return 0;
7 3 if (p < end && *p != ' ' && *p != '\t') return 0;
1608 324 6 while (p < end && (*p == ' ' || *p == '\t')) p++;
189 135 while (p < end && (*p == ' ' || *p == '\t')) p++;
3 132 while (p < end && (*p == ' ' || *p == '\t')) p++;
1611 216 6 while (be > bs && (be[-1] == ' ' || be[-1] == '\t')) be--;
84 132 while (be > bs && (be[-1] == ' ' || be[-1] == '\t')) be--;
0 132 while (be > bs && (be[-1] == ' ' || be[-1] == '\t')) be--;
1614 292 9 while (trim > bs && trim[-1] == '#') trim--;
163 129 while (trim > bs && trim[-1] == '#') trim--;
1615 31 107 if (trim < be && (trim == bs || trim[-1] == ' ' || trim[-1] == '\t')) {
28 3 if (trim < be && (trim == bs || trim[-1] == ' ' || trim[-1] == '\t')) {
12 16 if (trim < be && (trim == bs || trim[-1] == ' ' || trim[-1] == '\t')) {
0 12 if (trim < be && (trim == bs || trim[-1] == ' ' || trim[-1] == '\t')) {
1617 41 3 while (be > bs && (be[-1] == ' ' || be[-1] == '\t')) be--;
25 16 while (be > bs && (be[-1] == ' ' || be[-1] == '\t')) be--;
0 16 while (be > bs && (be[-1] == ' ' || be[-1] == '\t')) be--;
1634 4602 9 while (p < end && *p == ' ' && lead < 3) { p++; lead++; }
424 4178 while (p < end && *p == ' ' && lead < 3) { p++; lead++; }
375 49 while (p < end && *p == ' ' && lead < 3) { p++; lead++; }
1635 9 4227 if (p >= end) return 0;
1637 4032 195 if (ch != '`' && ch != '~') return 0;
3996 36 if (ch != '`' && ch != '~') return 0;
1638 658 119 while (p < end && *p == ch) { p++; n++; }
546 112 while (p < end && *p == ch) { p++; n++; }
1639 105 126 if (n < 3) return 0;
1640 55 98 while (p < end && (*p == ' ' || *p == '\t')) p++;
27 28 while (p < end && (*p == ' ' || *p == '\t')) p++;
0 28 while (p < end && (*p == ' ' || *p == '\t')) p++;
1643 28 98 while (ie > is && (ie[-1] == ' ' || ie[-1] == '\t')) ie--;
0 28 while (ie > is && (ie[-1] == ' ' || ie[-1] == '\t')) ie--;
0 28 while (ie > is && (ie[-1] == ' ' || ie[-1] == '\t')) ie--;
1644 102 24 if (ch == '`') {
1645 9 106 for (q = is; q < ie; q++) if (*q == '`') return 0;
115 93 for (q = is; q < ie; q++) if (*q == '`') return 0;
1658 336 15 while (p < end && *p == ' ' && lead < 3) { p++; lead++; }
99 237 while (p < end && *p == ' ' && lead < 3) { p++; lead++; }
93 6 while (p < end && *p == ' ' && lead < 3) { p++; lead++; }
1659 492 117 while (p < end && *p == ch) { p++; n++; }
351 141 while (p < end && *p == ch) { p++; n++; }
1660 162 96 if (n < min_len) return 0;
1661 6 93 while (p < end) {
1662 3 3 if (*p != ' ' && *p != '\t') return 0;
3 0 if (*p != ' ' && *p != '\t') return 0;
1671 6342 27 while (q < end && *q == ' ' && lead < 3) { q++; lead++; }
810 5532 while (q < end && *q == ' ' && lead < 3) { q++; lead++; }
737 73 while (q < end && *q == ' ' && lead < 3) { q++; lead++; }
1672 5605 27 if (q >= end || *q != '>') return 0;
5334 271 if (q >= end || *q != '>') return 0;
1674 247 24 if (q < end && (*q == ' ' || *q == '\t')) q++;
34 213 if (q < end && (*q == ' ' || *q == '\t')) q++;
0 34 if (q < end && (*q == ' ' || *q == '\t')) q++;
1689 6227 9 while (p < end && *p == ' ' && lead < 3) { p++; col++; lead++; }
861 5366 while (p < end && *p == ' ' && lead < 3) { p++; col++; lead++; }
788 73 while (p < end && *p == ' ' && lead < 3) { p++; col++; lead++; }
1690 9 5439 if (p >= end) return 0;
1693 4689 750 if (m == '-' || m == '+' || m == '*') {
4677 12 if (m == '-' || m == '+' || m == '*') {
329 4348 if (m == '-' || m == '+' || m == '*') {
1696 3978 370 } else if (m >= '0' && m <= '9') {
221 3757 } else if (m >= '0' && m <= '9') {
1699 526 6 while (q < end && *q >= '0' && *q <= '9' && digits < 9) {
323 203 while (q < end && *q >= '0' && *q <= '9' && digits < 9) {
314 9 while (q < end && *q >= '0' && *q <= '9' && digits < 9) {
311 3 while (q < end && *q >= '0' && *q <= '9' && digits < 9) {
1703 221 0 if (digits == 0 || q >= end) return 0;
6 215 if (digits == 0 || q >= end) return 0;
1704 30 185 if (*q != '.' && *q != ')') return 0;
15 15 if (*q != '.' && *q != ')') return 0;
1715 1231 60 if (!empty) {
1716 946 285 if (*p == ' ') {
1717 2024 12 while (p < end && spaces_after < 5 && *p == ' ') { p++; spaces_after++; col++; }
2015 9 while (p < end && spaces_after < 5 && *p == ' ') { p++; spaces_after++; col++; }
1090 925 while (p < end && spaces_after < 5 && *p == ' ') { p++; spaces_after++; col++; }
1718 0 285 } else if (*p == '\t') {
1728 9 997 if (spaces_after >= 5) {
1733 72 934 if (empty) {
1752 934 0 while (p < end && *p == ' ' && lead < 3) { p++; lead++; }
177 757 while (p < end && *p == ' ' && lead < 3) { p++; lead++; }
147 30 while (p < end && *p == ' ' && lead < 3) { p++; lead++; }
1753 0 787 if (p >= end) return 0;
1755 758 29 if (c != '=' && c != '-') return 0;
632 126 if (c != '=' && c != '-') return 0;
1756 559 78 while (p < end && *p == c) { p++; n++; }
482 77 while (p < end && *p == c) { p++; n++; }
1757 166 81 while (p < end && (*p == ' ' || *p == '\t')) p++;
92 74 while (p < end && (*p == ' ' || *p == '\t')) p++;
0 74 while (p < end && (*p == ' ' || *p == '\t')) p++;
1758 81 74 if (p != end || n < 1) return 0;
0 81 if (p != end || n < 1) return 0;
1759 26 55 return (c == '=') ? 1 : 2;
1779 221 2239 if (sc) {
1795 458 2002 if (ctx->flags & MDS_FLAG_FOOTNOTES) {
1801 6452 2460 while (p < end) {
1819 43 6409 if (memchr(p, '\t', (size_t)(le - p))) {
1823 137 3 while (ws_end < le) {
1825 101 36 if (c == ' ' || c == '\t') {
43 58 if (c == ' ' || c == '\t') {
1826 43 36 if (c == '\t') saw_tab = 1;
1831 3 55 if (c == '>') { ws_end++; continue; }
1833 49 6 if ((c == '-' || c == '+' || c == '*') &&
49 0 if ((c == '-' || c == '+' || c == '*') &&
9 40 if ((c == '-' || c == '+' || c == '*') &&
1834 15 0 ws_end + 1 < le &&
1835 12 3 (ws_end[1] == ' ' || ws_end[1] == '\t')) {
12 0 (ws_end[1] == ' ' || ws_end[1] == '\t')) {
1839 34 6 if (c >= '0' && c <= '9') {
0 34 if (c >= '0' && c <= '9') {
1842 0 0 while (q < le && *q >= '0' && *q <= '9' && digits < 9) { q++; digits++; }
0 0 while (q < le && *q >= '0' && *q <= '9' && digits < 9) { q++; digits++; }
0 0 while (q < le && *q >= '0' && *q <= '9' && digits < 9) { q++; digits++; }
0 0 while (q < le && *q >= '0' && *q <= '9' && digits < 9) { q++; digits++; }
1843 0 0 if (q < le && (*q == '.' || *q == ')') &&
0 0 if (q < le && (*q == '.' || *q == ')') &&
0 0 if (q < le && (*q == '.' || *q == ')') &&
1844 0 0 q + 1 < le && (q[1] == ' ' || q[1] == '\t')) {
0 0 q + 1 < le && (q[1] == ' ' || q[1] == '\t')) {
0 0 q + 1 < le && (q[1] == ' ' || q[1] == '\t')) {
1850 28 15 if (saw_tab) {
1859 73 28 for (s = p; s < ws_end; s++) {
1860 43 30 if (*s == '\t') {
1862 151 43 while (adv-- > 0) { *dst++ = ' '; col++; }
1865 25 3 if (le > ws_end) memcpy(dst, ws_end, (size_t)(le - ws_end));
1886 458 2002 if ((ctx->flags & MDS_FLAG_FOOTNOTES) && ctx->footnotes && ctx->footnotes->len) {
9 449 if ((ctx->flags & MDS_FLAG_FOOTNOTES) && ctx->footnotes && ctx->footnotes->len) {
9 0 if ((ctx->flags & MDS_FLAG_FOOTNOTES) && ctx->footnotes && ctx->footnotes->len) {
1889 9 0 if (MDS_LIKELY(cb.enter_block != NULL)) {
1898 18 9 while (mds_render_html_used_footnote(ud, emit_n, &lbl, &llen)) emit_n++;
1900 9 0 if (emit_n == 0) {
1908 18 9 for (k = 0; k < emit_n; k++) {
1913 0 18 if (!fn) continue;
1920 18 0 if (fn->blen) {
1929 18 0 if (cb.leave_block != NULL)
1932 9 0 if (cb.leave_block != NULL)
1938 221 2239 if (sc) {
1956 0 3 if (!s) return;
1983 264 6188 if (b->leaf == LF_CODE_FENCED) {
1988 81 258 for (i = 1; i < b->depth; i++) {
1990 9 72 if (c->kind == CT_QUOTE) {
1991 6 3 if (!try_open_quote(&p, line_end)) {
1997 36 36 } else if (c->kind == CT_LIST_ITEM) {
1999 30 6 if (!blank && col < c->content_col) {
0 30 if (!blank && col < c->content_col) {
2007 93 165 if (is_fence_close(p, line_end, b->fence_char, b->fence_len)) {
2013 186 12 while (cp < line_end && strip > 0 && *cp == ' ') { cp++; strip--; }
48 138 while (cp < line_end && strip > 0 && *cp == ' ') { cp++; strip--; }
33 15 while (cp < line_end && strip > 0 && *cp == ' ') { cp++; strip--; }
2016 153 12 if (add) memcpy(b->code_body + b->code_len, cp, add);
2024 321 5867 if (b->leaf == LF_HTML) {
2026 12 315 for (i = 1; i < b->depth; i++) {
2028 6 6 if (c->kind == CT_QUOTE) {
2029 3 3 if (!try_open_quote(&p, line_end)) {
2034 3 3 } else if (c->kind == CT_LIST_ITEM) {
2036 3 0 if (!blank && col < c->content_col) {
3 0 if (!blank && col < c->content_col) {
2044 87 228 if (blank && (b->html_type == 6 || b->html_type == 7)) {
39 48 if (blank && (b->html_type == 6 || b->html_type == 7)) {
3 36 if (blank && (b->html_type == 6 || b->html_type == 7)) {
2050 228 36 if (add) memcpy(b->html_body + b->html_len, p, add);
2053 27 237 if (detect_html_block_end(b->html_type, p, line_end, blank)) {
2063 1648 5526 for (i = 1; i < b->depth; i++) {
2065 155 1493 if (c->kind == CT_QUOTE) {
2066 89 66 if (try_open_quote(&p, line_end)) { matched = i + 1; }
2068 748 745 } else if (c->kind == CT_LIST) {
2070 745 0 } else if (c->kind == CT_LIST_ITEM) {
2072 202 543 if (blank) { matched = i + 1; }
2073 259 284 else if (col >= c->content_col) {
2077 15 244 if (c->is_empty && c->blank_after_empty) {
3 12 if (c->is_empty && c->blank_after_empty) {
2078 3 0 if (i > 0 && b->stack[i-1].kind == CT_LIST) matched = i - 1;
3 0 if (i > 0 && b->stack[i-1].kind == CT_LIST) matched = i - 1;
2095 4829 1050 if (!blank && is_blank(p, line_end)) blank = 1;
24 4805 if (!blank && is_blank(p, line_end)) blank = 1;
2097 1074 4805 if (blank) {
2102 78 996 if (b->leaf == LF_CODE_INDENTED) {
2104 6 72 if (col >= 4) {
2106 0 6 while (b->pending_blanks > 0) {
2114 3 3 if (add) memcpy(b->code_body + b->code_len, p, add);
2123 3 69 if (matched < b->depth) {
2125 3 0 for (i = matched; i < b->depth; i++) {
2126 3 0 if (b->stack[i].kind == CT_QUOTE) { has_unmatched_quote = 1; break; }
2128 3 0 if (has_unmatched_quote) {
2149 897 102 if (b->leaf == LF_PARAGRAPH) finalize_leaf(b);
2153 1391 999 for (i = 0; i < matched; i++) {
2154 178 1213 if (b->stack[i].kind == CT_LIST_ITEM) deepest_li = i;
2156 155 844 if (deepest_li >= 0) {
2157 3 152 for (i = deepest_li + 1; i < matched; i++) {
2158 3 0 if (b->stack[i].kind == CT_QUOTE) { has_quote_above_li = 1; break; }
2161 996 3 if (!has_quote_above_li) b->blank_pending = 1;
2163 1409 999 for (i = 0; i < b->depth; i++) {
2164 184 1225 if (b->stack[i].kind == CT_LIST_ITEM && b->stack[i].is_empty)
6 178 if (b->stack[i].kind == CT_LIST_ITEM && b->stack[i].is_empty)
2171 18 981 if (matched < b->depth) {
2172 18 6 for (i = matched; i < b->depth; i++) {
2173 12 6 if (b->stack[i].kind == CT_QUOTE) {
2184 335 4470 if (matched < b->depth && b->leaf == LF_PARAGRAPH) {
242 93 if (matched < b->depth && b->leaf == LF_PARAGRAPH) {
2194 242 0 if (!(_f & MDS_FLAG_NO_THEMATIC_BREAK) && try_thematic_break(p, line_end)) ;
24 218 if (!(_f & MDS_FLAG_NO_THEMATIC_BREAK) && try_thematic_break(p, line_end)) ;
2195 218 0 else if (!(_f & MDS_FLAG_NO_HEADINGS) && try_atx_heading(p, line_end, &lvl, &ds, &de)) ;
0 218 else if (!(_f & MDS_FLAG_NO_HEADINGS) && try_atx_heading(p, line_end, &lvl, &ds, &de)) ;
2196 218 0 else if (!(_f & MDS_FLAG_NO_FENCED_CODE) && try_fence_open(p, line_end, &fi, &fc, &fl, &ifs, &ife)) ;
3 215 else if (!(_f & MDS_FLAG_NO_FENCED_CODE) && try_fence_open(p, line_end, &fi, &fc, &fl, &ifs, &ife)) ;
2197 215 0 else if (!(_f & MDS_FLAG_NO_HTML) && detect_html_block_start(p, line_end, 0)) ;
0 215 else if (!(_f & MDS_FLAG_NO_HTML) && detect_html_block_start(p, line_end, 0)) ;
2198 215 0 else if (!(_f & MDS_FLAG_NO_QUOTES) && try_open_quote(&tp, line_end)) ;
0 215 else if (!(_f & MDS_FLAG_NO_QUOTES) && try_open_quote(&tp, line_end)) ;
2201 0 215 _both_lists = (_f & MDS_FLAG_NO_ORDERED_LISTS) && (_f & MDS_FLAG_NO_UNORDERED_LISTS);
0 0 _both_lists = (_f & MDS_FLAG_NO_ORDERED_LISTS) && (_f & MDS_FLAG_NO_UNORDERED_LISTS);
2202 215 0 if (!_both_lists && try_open_list_item(&tp, line_end, &ord, &st, &mk, &cc, &em)) {
171 44 if (!_both_lists && try_open_list_item(&tp, line_end, &ord, &st, &mk, &cc, &em)) {
2203 23 148 if ((ord && (_f & MDS_FLAG_NO_ORDERED_LISTS)) ||
23 0 if ((ord && (_f & MDS_FLAG_NO_ORDERED_LISTS)) ||
2204 148 23 (!ord && (_f & MDS_FLAG_NO_UNORDERED_LISTS))) lazy = 1;
0 148 (!ord && (_f & MDS_FLAG_NO_UNORDERED_LISTS))) lazy = 1;
2207 4761 44 if (!lazy) close_containers_to(b, matched);
2214 4761 44 if (!lazy && b->depth > 1 && top(b)->kind == CT_LIST) {
507 4254 if (!lazy && b->depth > 1 && top(b)->kind == CT_LIST) {
267 240 if (!lazy && b->depth > 1 && top(b)->kind == CT_LIST) {
2219 0 267 if (!((b->ctx->flags & MDS_FLAG_NO_ORDERED_LISTS) &&
2222 223 5 ord2 == lst->ordered && mk2 == lst->marker) {
217 6 ord2 == lst->ordered && mk2 == lst->marker) {
2225 50 217 if (!keep) {
2236 945 3860 if (b->blank_pending) {
2238 1184 945 for (i = 0; i < b->depth; i++)
2239 126 1058 if (b->stack[i].kind == CT_LIST) deepest = i;
2240 117 828 if (deepest >= 0) b->stack[deepest].pending_blank = 1;
2248 5666 4805 for (i = 0; i < b->depth; i++) {
2249 487 5179 if (b->stack[i].kind == CT_LIST && b->stack[i].pending_blank) {
117 370 if (b->stack[i].kind == CT_LIST && b->stack[i].pending_blank) {
2260 256 4549 if (col >= 4 && b->leaf != LF_PARAGRAPH &&
217 39 if (col >= 4 && b->leaf != LF_PARAGRAPH &&
2261 216 1 !(b->ctx->flags & MDS_FLAG_NO_INDENTED_CODE)) {
2265 152 64 if (b->leaf != LF_CODE_INDENTED) {
2272 30 64 while (b->pending_blanks > 0) {
2280 216 0 if (add) memcpy(b->code_body + b->code_len, p, add);
2285 54 4535 if (b->leaf == LF_CODE_INDENTED) {
2296 3757 832 if (b->leaf == LF_PARAGRAPH && !(b->ctx->flags & MDS_FLAG_NO_HEADINGS) && !lazy) {
1 831 if (b->leaf == LF_PARAGRAPH && !(b->ctx->flags & MDS_FLAG_NO_HEADINGS) && !lazy) {
44 787 if (b->leaf == LF_PARAGRAPH && !(b->ctx->flags & MDS_FLAG_NO_HEADINGS) && !lazy) {
2298 706 81 if (sx) {
2305 81 0 if (!(b->ctx->flags & MDS_FLAG_NO_REFERENCES) && b->para_len) {
81 0 if (!(b->ctx->flags & MDS_FLAG_NO_REFERENCES) && b->para_len) {
2308 84 3 while (rp < re) {
2311 78 6 if (!parse_linkref(rp, re, &nrp,
2317 78 3 while (rp < re && (*rp == ' ' || *rp == '\t' || *rp == '\n')) rp++;
0 78 while (rp < re && (*rp == ' ' || *rp == '\t' || *rp == '\n')) rp++;
0 78 while (rp < re && (*rp == ' ' || *rp == '\t' || *rp == '\n')) rp++;
0 78 while (rp < re && (*rp == ' ' || *rp == '\t' || *rp == '\n')) rp++;
2318 3 78 if (rp == re) all_refs = 1;
2320 3 78 if (!all_refs) {
2342 5247 1 if (!(_of & MDS_FLAG_NO_QUOTES) && try_open_quote(&p, line_end)) {
176 5071 if (!(_of & MDS_FLAG_NO_QUOTES) && try_open_quote(&p, line_end)) {
2344 0 176 if (!push(b, CT_QUOTE)) { p = before; break; }
2349 4 5068 _both_lists2 = (_of & MDS_FLAG_NO_ORDERED_LISTS) && (_of & MDS_FLAG_NO_UNORDERED_LISTS);
2 2 _both_lists2 = (_of & MDS_FLAG_NO_ORDERED_LISTS) && (_of & MDS_FLAG_NO_UNORDERED_LISTS);
2355 4966 2 if (!_both_lists2 && try_open_list_item(&p, line_end, &ord, &st, &mk, &cc, &em)) {
607 4359 if (!_both_lists2 && try_open_list_item(&p, line_end, &ord, &st, &mk, &cc, &em)) {
2356 137 470 if ((ord && (_of & MDS_FLAG_NO_ORDERED_LISTS)) ||
135 2 if ((ord && (_of & MDS_FLAG_NO_ORDERED_LISTS)) ||
2357 470 135 (!ord && (_of & MDS_FLAG_NO_UNORDERED_LISTS))) { p = save; break; }
2 468 (!ord && (_of & MDS_FLAG_NO_UNORDERED_LISTS))) { p = save; break; }
2361 80 523 if (b->leaf == LF_PARAGRAPH && (em || (ord && st != 1))) {
71 9 if (b->leaf == LF_PARAGRAPH && (em || (ord && st != 1))) {
8 63 if (b->leaf == LF_PARAGRAPH && (em || (ord && st != 1))) {
3 5 if (b->leaf == LF_PARAGRAPH && (em || (ord && st != 1))) {
2366 591 0 t = (b->depth > 0) ? top(b) : NULL;
2367 591 0 nested_inside_item = (t && t->kind == CT_LIST_ITEM);
68 523 nested_inside_item = (t && t->kind == CT_LIST_ITEM);
2368 214 377 same_list = (t && t->kind == CT_LIST
2369 591 0 && t->ordered == ord && t->marker == mk);
214 0 && t->ordered == ord && t->marker == mk);
214 0 && t->ordered == ord && t->marker == mk);
2370 68 523 if (nested_inside_item) {
2372 0 68 if (!push(b, CT_LIST)) { p = save; break; }
2379 309 214 } else if (same_list) {
2387 15 294 while (b->depth > 1 &&
2388 0 15 (top(b)->kind == CT_LIST_ITEM || top(b)->kind == CT_LIST)) {
0 15 (top(b)->kind == CT_LIST_ITEM || top(b)->kind == CT_LIST)) {
2392 0 309 if (!push(b, CT_LIST)) { p = save; break; }
2400 0 591 if (!push(b, CT_LIST_ITEM)) break;
2406 30 561 if (em) return;
2417 3808 673 if (b->leaf != LF_PARAGRAPH && b->leaf != LF_CODE_INDENTED &&
3808 0 if (b->leaf != LF_PARAGRAPH && b->leaf != LF_CODE_INDENTED &&
2418 3807 1 !(b->ctx->flags & MDS_FLAG_NO_INDENTED_CODE)) {
2420 18 3789 if (col2 >= 4) {
2429 18 0 if (add) memcpy(b->code_body + b->code_len, p, add);
2436 4462 1 if (!(b->ctx->flags & MDS_FLAG_NO_HTML)) {
2439 200 4262 if (htype) {
2448 200 0 if (add) memcpy(b->html_body + b->html_len, p, add);
2451 34 166 if (detect_html_block_end(htype, p, line_end, blank)) {
2464 129 9 if (be > bs) sax_inline_text(b, bs, (size_t)(be - bs));
2477 6 101 while (b->depth > 1 && top(b)->kind == CT_LIST) {
3 3 while (b->depth > 1 && top(b)->kind == CT_LIST) {
2496 19 95 if (iln) {
2501 181 19 for (r = 0; r < iln; r++) {
2503 3 178 if (ch == '\\' && r + 1 < iln) {
3 0 if (ch == '\\' && r + 1 < iln) {
2505 3 0 if ((nx >= 0x21 && nx <= 0x2F) ||
0 3 if ((nx >= 0x21 && nx <= 0x2F) ||
0 0 if ((nx >= 0x21 && nx <= 0x2F) ||
2506 0 0 (nx >= 0x3A && nx <= 0x40) ||
0 0 (nx >= 0x3A && nx <= 0x40) ||
2507 0 0 (nx >= 0x5B && nx <= 0x60) ||
0 0 (nx >= 0x5B && nx <= 0x60) ||
2508 0 0 (nx >= 0x7B && nx <= 0x7E)) {
2526 3261 646 if (b->leaf != LF_PARAGRAPH) {
2532 4135 9 while (tp < line_end && *tp == ' ' && lead < 3) { tp++; lead++; }
277 3858 while (tp < line_end && *tp == ' ' && lead < 3) { tp++; lead++; }
237 40 while (tp < line_end && *tp == ' ' && lead < 3) { tp++; lead++; }
2533 643 3264 if (b->para_len > 0) {