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

Function parse_codefence

libraries/hoedown/src/document.c:1424–1450  ·  view source on GitHub ↗

expects single line, checks if it's a codefence and extracts language */

Source from the content-addressed store, hash-verified

1422
1423/* expects single line, checks if it's a codefence and extracts language */
1424static size_t
1425parse_codefence(uint8_t *data, size_t size, hoedown_buffer *lang, size_t *width, uint8_t *chr)
1426{
1427 size_t i, w, lang_start;
1428
1429 i = w = is_codefence(data, size, width, chr);
1430 if (i == 0)
1431 return 0;
1432
1433 while (i < size && _isspace(data[i]))
1434 i++;
1435
1436 lang_start = i;
1437
1438 while (i < size && !_isspace(data[i]))
1439 i++;
1440
1441 lang->data = data + lang_start;
1442 lang->size = i - lang_start;
1443
1444 /* Avoid parsing a codespan as a fence */
1445 i = lang_start + 2;
1446 while (i < size && !(data[i] == *chr && data[i-1] == *chr && data[i-2] == *chr)) i++;
1447 if (i < size) return 0;
1448
1449 return w;
1450}
1451
1452/* is_atxheader • returns whether the line is a hash-prefixed header */
1453static int

Callers 1

parse_fencedcodeFunction · 0.85

Calls 2

is_codefenceFunction · 0.85
_isspaceFunction · 0.85

Tested by

no test coverage detected