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

Function hoedown_document_render_inline

libraries/hoedown/src/document.c:2896–2941  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2894}
2895
2896void
2897hoedown_document_render_inline(hoedown_document *doc, hoedown_buffer *ob, const uint8_t *data, size_t size)
2898{
2899 size_t i = 0, mark;
2900 hoedown_buffer *text = hoedown_buffer_new(64);
2901
2902 /* reset the references table */
2903 memset(&doc->refs, 0x0, REF_TABLE_SIZE * sizeof(void *));
2904
2905 /* first pass: expand tabs and process newlines */
2906 hoedown_buffer_grow(text, size);
2907 while (1) {
2908 mark = i;
2909 while (i < size && data[i] != '\n' && data[i] != '\r')
2910 i++;
2911
2912 expand_tabs(text, data + mark, i - mark);
2913
2914 if (i >= size)
2915 break;
2916
2917 while (i < size && (data[i] == '\n' || data[i] == '\r')) {
2918 /* add one \n per newline */
2919 if (data[i] == '\n' || (i + 1 < size && data[i + 1] != '\n'))
2920 hoedown_buffer_putc(text, '\n');
2921 i++;
2922 }
2923 }
2924
2925 /* second pass: actual rendering */
2926 hoedown_buffer_grow(ob, text->size + (text->size >> 1));
2927
2928 if (doc->md.doc_header)
2929 doc->md.doc_header(ob, 1, &doc->data);
2930
2931 parse_inline(ob, doc, text->data, text->size);
2932
2933 if (doc->md.doc_footer)
2934 doc->md.doc_footer(ob, 1, &doc->data);
2935
2936 /* clean-up */
2937 hoedown_buffer_free(text);
2938
2939 assert(doc->work_bufs[BUFFER_SPAN].size == 0);
2940 assert(doc->work_bufs[BUFFER_BLOCK].size == 0);
2941}
2942
2943void
2944hoedown_document_free(hoedown_document *doc)

Callers

nothing calls this directly

Calls 6

hoedown_buffer_newFunction · 0.85
hoedown_buffer_growFunction · 0.85
expand_tabsFunction · 0.85
hoedown_buffer_putcFunction · 0.85
parse_inlineFunction · 0.85
hoedown_buffer_freeFunction · 0.85

Tested by

no test coverage detected