MCPcopy Create free account
hub / github.com/commonmark/cmark / parse_code_block_prefix

Function parse_code_block_prefix

src/blocks.c:819–860  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

817}
818
819static 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
862static bool parse_html_block_prefix(cmark_parser *parser,
863 cmark_node *container) {

Callers 1

check_open_blocksFunction · 0.85

Calls 4

S_advance_offsetFunction · 0.85
peek_atFunction · 0.85
finalizeFunction · 0.85
S_is_space_or_tabFunction · 0.85

Tested by

no test coverage detected