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

Function is_footnote

libraries/hoedown/src/document.c:2479–2581  ·  view source on GitHub ↗

is_footnote • returns whether a line is a footnote definition or not */

Source from the content-addressed store, hash-verified

2477
2478/* is_footnote • returns whether a line is a footnote definition or not */
2479static int
2480is_footnote(const uint8_t *data, size_t beg, size_t end, size_t *last, struct footnote_list *list)
2481{
2482 size_t i = 0;
2483 hoedown_buffer *contents = 0;
2484 size_t ind = 0;
2485 int in_empty = 0;
2486 size_t start = 0;
2487
2488 size_t id_offset, id_end;
2489
2490 /* up to 3 optional leading spaces */
2491 if (beg + 3 >= end) return 0;
2492 if (data[beg] == ' ') { i = 1;
2493 if (data[beg + 1] == ' ') { i = 2;
2494 if (data[beg + 2] == ' ') { i = 3;
2495 if (data[beg + 3] == ' ') return 0; } } }
2496 i += beg;
2497
2498 /* id part: caret followed by anything between brackets */
2499 if (data[i] != '[') return 0;
2500 i++;
2501 if (i >= end || data[i] != '^') return 0;
2502 i++;
2503 id_offset = i;
2504 while (i < end && data[i] != '\n' && data[i] != '\r' && data[i] != ']')
2505 i++;
2506 if (i >= end || data[i] != ']') return 0;
2507 id_end = i;
2508
2509 /* spacer: colon (space | tab)* newline? (space | tab)* */
2510 i++;
2511 if (i >= end || data[i] != ':') return 0;
2512 i++;
2513
2514 /* getting content buffer */
2515 contents = hoedown_buffer_new(64);
2516
2517 start = i;
2518
2519 /* process lines similar to a list item */
2520 while (i < end) {
2521 while (i < end && data[i] != '\n' && data[i] != '\r') i++;
2522
2523 /* process an empty line */
2524 if (is_empty(data + start, i - start)) {
2525 in_empty = 1;
2526 if (i < end && (data[i] == '\n' || data[i] == '\r')) {
2527 i++;
2528 if (i < end && data[i] == '\n' && data[i - 1] == '\r') i++;
2529 }
2530 start = i;
2531 continue;
2532 }
2533
2534 /* calculating the indentation */
2535 ind = 0;
2536 while (ind < 4 && start + ind < end && data[start + ind] == ' ')

Callers 1

hoedown_document_renderFunction · 0.85

Calls 7

hoedown_buffer_newFunction · 0.85
is_emptyFunction · 0.85
hoedown_buffer_putcFunction · 0.85
hoedown_buffer_putFunction · 0.85
create_footnote_refFunction · 0.85
add_footnote_refFunction · 0.85
free_footnote_refFunction · 0.85

Tested by

no test coverage detected