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

Function find_emph_char

libraries/hoedown/src/document.c:510–600  ·  view source on GitHub ↗

find_emph_char • looks for the next emph uint8_t, skipping other constructs */

Source from the content-addressed store, hash-verified

508
509/* find_emph_char • looks for the next emph uint8_t, skipping other constructs */
510static size_t
511find_emph_char(uint8_t *data, size_t size, uint8_t c)
512{
513 size_t i = 0;
514
515 while (i < size) {
516 while (i < size && data[i] != c && data[i] != '[' && data[i] != '`')
517 i++;
518
519 if (i == size)
520 return 0;
521
522 /* not counting escaped chars */
523 if (is_escaped(data, i)) {
524 i++; continue;
525 }
526
527 if (data[i] == c)
528 return i;
529
530 /* skipping a codespan */
531 if (data[i] == '`') {
532 size_t span_nb = 0, bt;
533 size_t tmp_i = 0;
534
535 /* counting the number of opening backticks */
536 while (i < size && data[i] == '`') {
537 i++; span_nb++;
538 }
539
540 if (i >= size) return 0;
541
542 /* finding the matching closing sequence */
543 bt = 0;
544 while (i < size && bt < span_nb) {
545 if (!tmp_i && data[i] == c) tmp_i = i;
546 if (data[i] == '`') bt++;
547 else bt = 0;
548 i++;
549 }
550
551 /* not a well-formed codespan; use found matching emph char */
552 if (i >= size) return tmp_i;
553 }
554 /* skipping a link */
555 else if (data[i] == '[') {
556 size_t tmp_i = 0;
557 uint8_t cc;
558
559 i++;
560 while (i < size && data[i] != ']') {
561 if (!tmp_i && data[i] == c) tmp_i = i;
562 i++;
563 }
564
565 i++;
566 while (i < size && _isspace(data[i]))
567 i++;

Callers 7

parse_emph1Function · 0.85
parse_emph2Function · 0.85
parse_emph3Function · 0.85
char_quoteFunction · 0.85
char_linkFunction · 0.85
char_superscriptFunction · 0.85
parse_table_rowFunction · 0.85

Calls 2

is_escapedFunction · 0.85
_isspaceFunction · 0.85

Tested by

no test coverage detected