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

Function is_hrule

libraries/hoedown/src/document.c:1359–1387  ·  view source on GitHub ↗

is_hrule • returns whether a line is a horizontal rule */

Source from the content-addressed store, hash-verified

1357
1358/* is_hrule • returns whether a line is a horizontal rule */
1359static int
1360is_hrule(uint8_t *data, size_t size)
1361{
1362 size_t i = 0, n = 0;
1363 uint8_t c;
1364
1365 /* skipping initial spaces */
1366 if (size < 3) return 0;
1367 if (data[0] == ' ') { i++;
1368 if (data[1] == ' ') { i++;
1369 if (data[2] == ' ') { i++; } } }
1370
1371 /* looking at the hrule uint8_t */
1372 if (i + 2 >= size
1373 || (data[i] != '*' && data[i] != '-' && data[i] != '_'))
1374 return 0;
1375 c = data[i];
1376
1377 /* the whole line must be the char or space */
1378 while (i < size && data[i] != '\n') {
1379 if (data[i] == c) n++;
1380 else if (data[i] != ' ')
1381 return 0;
1382
1383 i++;
1384 }
1385
1386 return n >= 3;
1387}
1388
1389/* check if a line is a code fence; return the
1390 * end of the code fence. if passed, width of

Callers 3

parse_paragraphFunction · 0.85
parse_listitemFunction · 0.85
parse_blockFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected