MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / parse_fencedcode

Function parse_fencedcode

libraries/hoedown/src/document.c:1714–1754  ·  view source on GitHub ↗

parse_fencedcode • handles parsing of a block-level code fragment */

Source from the content-addressed store, hash-verified

1712
1713/* parse_fencedcode • handles parsing of a block-level code fragment */
1714static size_t
1715parse_fencedcode(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t size)
1716{
1717 hoedown_buffer text = { 0, 0, 0, 0, NULL, NULL, NULL };
1718 hoedown_buffer lang = { 0, 0, 0, 0, NULL, NULL, NULL };
1719 size_t i = 0, text_start, line_start;
1720 size_t w, w2;
1721 size_t width, width2;
1722 uint8_t chr, chr2;
1723
1724 /* parse codefence line */
1725 while (i < size && data[i] != '\n')
1726 i++;
1727
1728 w = parse_codefence(data, i, &lang, &width, &chr);
1729 if (!w)
1730 return 0;
1731
1732 /* search for end */
1733 i++;
1734 text_start = i;
1735 while ((line_start = i) < size) {
1736 while (i < size && data[i] != '\n')
1737 i++;
1738
1739 w2 = is_codefence(data + line_start, i - line_start, &width2, &chr2);
1740 if (w == w2 && width == width2 && chr == chr2 &&
1741 is_empty(data + (line_start+w), i - (line_start+w)))
1742 break;
1743
1744 i++;
1745 }
1746
1747 text.data = data + text_start;
1748 text.size = line_start - text_start;
1749
1750 if (doc->md.blockcode)
1751 doc->md.blockcode(ob, text.size ? &text : NULL, lang.size ? &lang : NULL, &doc->data);
1752
1753 return i;
1754}
1755
1756static size_t
1757parse_blockcode(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t size)

Callers 1

parse_blockFunction · 0.85

Calls 3

parse_codefenceFunction · 0.85
is_codefenceFunction · 0.85
is_emptyFunction · 0.85

Tested by

no test coverage detected