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

Function parse_listitem

libraries/hoedown/src/document.c:1799–1932  ·  view source on GitHub ↗

parse_listitem • parsing of a single list item */ assuming initial prefix is already removed */

Source from the content-addressed store, hash-verified

1797/* parse_listitem • parsing of a single list item */
1798/* assuming initial prefix is already removed */
1799static size_t
1800parse_listitem(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t size, hoedown_list_flags *flags)
1801{
1802 hoedown_buffer *work = 0, *inter = 0;
1803 size_t beg = 0, end, pre, sublist = 0, orgpre = 0, i;
1804 int in_empty = 0, has_inside_empty = 0, in_fence = 0;
1805
1806 /* keeping track of the first indentation prefix */
1807 while (orgpre < 3 && orgpre < size && data[orgpre] == ' ')
1808 orgpre++;
1809
1810 beg = prefix_uli(data, size);
1811 if (!beg)
1812 beg = prefix_oli(data, size);
1813
1814 if (!beg)
1815 return 0;
1816
1817 /* skipping to the beginning of the following line */
1818 end = beg;
1819 while (end < size && data[end - 1] != '\n')
1820 end++;
1821
1822 /* getting working buffers */
1823 work = newbuf(doc, BUFFER_SPAN);
1824 inter = newbuf(doc, BUFFER_SPAN);
1825
1826 /* putting the first line into the working buffer */
1827 hoedown_buffer_put(work, data + beg, end - beg);
1828 beg = end;
1829
1830 /* process the following lines */
1831 while (beg < size) {
1832 size_t has_next_uli = 0, has_next_oli = 0;
1833
1834 end++;
1835
1836 while (end < size && data[end - 1] != '\n')
1837 end++;
1838
1839 /* process an empty line */
1840 if (is_empty(data + beg, end - beg)) {
1841 in_empty = 1;
1842 beg = end;
1843 continue;
1844 }
1845
1846 /* calculating the indentation */
1847 i = 0;
1848 while (i < 4 && beg + i < end && data[beg + i] == ' ')
1849 i++;
1850
1851 pre = i;
1852
1853 if (doc->ext_flags & HOEDOWN_EXT_FENCED_CODE) {
1854 if (is_codefence(data + beg + i, end - beg - i, NULL, NULL))
1855 in_fence = !in_fence;
1856 }

Callers 1

parse_listFunction · 0.85

Calls 11

prefix_uliFunction · 0.85
prefix_oliFunction · 0.85
newbufFunction · 0.85
hoedown_buffer_putFunction · 0.85
is_emptyFunction · 0.85
is_codefenceFunction · 0.85
is_hruleFunction · 0.85
hoedown_buffer_putcFunction · 0.85
parse_blockFunction · 0.85
parse_inlineFunction · 0.85
popbufFunction · 0.85

Tested by

no test coverage detected