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

Function char_emphasis

libraries/hoedown/src/document.c:760–795  ·  view source on GitHub ↗

char_emphasis • single and double emphasis parsing */

Source from the content-addressed store, hash-verified

758
759/* char_emphasis • single and double emphasis parsing */
760static size_t
761char_emphasis(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size)
762{
763 uint8_t c = data[0];
764 size_t ret;
765
766 if (doc->ext_flags & HOEDOWN_EXT_NO_INTRA_EMPHASIS) {
767 if (offset > 0 && !_isspace(data[-1]) && data[-1] != '>' && data[-1] != '(')
768 return 0;
769 }
770
771 if (size > 2 && data[1] != c) {
772 /* spacing cannot follow an opening emphasis;
773 * strikethrough and highlight only takes two characters '~~' */
774 if (c == '~' || c == '=' || _isspace(data[1]) || (ret = parse_emph1(ob, doc, data + 1, size - 1, c)) == 0)
775 return 0;
776
777 return ret + 1;
778 }
779
780 if (size > 3 && data[1] == c && data[2] != c) {
781 if (_isspace(data[2]) || (ret = parse_emph2(ob, doc, data + 2, size - 2, c)) == 0)
782 return 0;
783
784 return ret + 2;
785 }
786
787 if (size > 4 && data[1] == c && data[2] == c && data[3] != c) {
788 if (c == '~' || c == '=' || _isspace(data[3]) || (ret = parse_emph3(ob, doc, data + 3, size - 3, c)) == 0)
789 return 0;
790
791 return ret + 3;
792 }
793
794 return 0;
795}
796
797
798/* char_linebreak • '\n' preceded by two spaces (assuming linebreak != 0) */

Callers

nothing calls this directly

Calls 4

_isspaceFunction · 0.85
parse_emph1Function · 0.85
parse_emph2Function · 0.85
parse_emph3Function · 0.85

Tested by

no test coverage detected