| 817 | } |
| 818 | |
| 819 | static bool parse_code_block_prefix(cmark_parser *parser, cmark_chunk *input, |
| 820 | cmark_node *container, |
| 821 | bool *should_continue) { |
| 822 | bool res = false; |
| 823 | |
| 824 | if (!container->as.code.fenced) { // indented |
| 825 | if (parser->indent >= CODE_INDENT) { |
| 826 | S_advance_offset(parser, input, CODE_INDENT, true); |
| 827 | res = true; |
| 828 | } else if (parser->blank) { |
| 829 | S_advance_offset(parser, input, parser->first_nonspace - parser->offset, |
| 830 | false); |
| 831 | res = true; |
| 832 | } |
| 833 | } else { // fenced |
| 834 | bufsize_t matched = 0; |
| 835 | |
| 836 | if (parser->indent <= 3 && (peek_at(input, parser->first_nonspace) == |
| 837 | container->as.code.fence_char)) { |
| 838 | matched = scan_close_code_fence(input, parser->first_nonspace); |
| 839 | } |
| 840 | |
| 841 | if (matched >= container->as.code.fence_length) { |
| 842 | // closing fence - and since we're at |
| 843 | // the end of a line, we can stop processing it: |
| 844 | *should_continue = false; |
| 845 | S_advance_offset(parser, input, matched, false); |
| 846 | parser->current = finalize(parser, container); |
| 847 | } else { |
| 848 | // skip opt. spaces of fence parser->offset |
| 849 | int i = container->as.code.fence_offset; |
| 850 | |
| 851 | while (i > 0 && S_is_space_or_tab(peek_at(input, parser->offset))) { |
| 852 | S_advance_offset(parser, input, 1, true); |
| 853 | i--; |
| 854 | } |
| 855 | res = true; |
| 856 | } |
| 857 | } |
| 858 | |
| 859 | return res; |
| 860 | } |
| 861 | |
| 862 | static bool parse_html_block_prefix(cmark_parser *parser, |
| 863 | cmark_node *container) { |
no test coverage detected