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

Function parse_atxheader

libraries/hoedown/src/document.c:1959–1991  ·  view source on GitHub ↗

parse_atxheader • parsing of atx-style headers */

Source from the content-addressed store, hash-verified

1957
1958/* parse_atxheader • parsing of atx-style headers */
1959static size_t
1960parse_atxheader(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t size)
1961{
1962 size_t level = 0;
1963 size_t i, end, skip;
1964
1965 while (level < size && level < 6 && data[level] == '#')
1966 level++;
1967
1968 for (i = level; i < size && data[i] == ' '; i++);
1969
1970 for (end = i; end < size && data[end] != '\n'; end++);
1971 skip = end;
1972
1973 while (end && data[end - 1] == '#')
1974 end--;
1975
1976 while (end && data[end - 1] == ' ')
1977 end--;
1978
1979 if (end > i) {
1980 hoedown_buffer *work = newbuf(doc, BUFFER_SPAN);
1981
1982 parse_inline(work, doc, data + i, end - i);
1983
1984 if (doc->md.header)
1985 doc->md.header(ob, work, (int)level, &doc->data);
1986
1987 popbuf(doc, BUFFER_SPAN);
1988 }
1989
1990 return skip;
1991}
1992
1993/* parse_footnote_def • parse a single footnote definition */
1994static void

Callers 1

parse_blockFunction · 0.85

Calls 3

newbufFunction · 0.85
parse_inlineFunction · 0.85
popbufFunction · 0.85

Tested by

no test coverage detected