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

Function char_escape

libraries/hoedown/src/document.c:906–935  ·  view source on GitHub ↗

char_escape • '\\' backslash escape */

Source from the content-addressed store, hash-verified

904
905/* char_escape • '\\' backslash escape */
906static size_t
907char_escape(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size)
908{
909 static const char *escape_chars = "\\`*_{}[]()#+-.!:|&<>^~=\"$";
910 hoedown_buffer work = { 0, 0, 0, 0, NULL, NULL, NULL };
911 size_t w;
912
913 if (size > 1) {
914 if (data[1] == '\\' && (doc->ext_flags & HOEDOWN_EXT_MATH) &&
915 size > 2 && (data[2] == '(' || data[2] == '[')) {
916 const char *end = (data[2] == '[') ? "\\\\]" : "\\\\)";
917 w = parse_math(ob, doc, data, offset, size, end, 3, data[2] == '[');
918 if (w) return w;
919 }
920
921 if (strchr(escape_chars, data[1]) == NULL)
922 return 0;
923
924 if (doc->md.normal_text) {
925 work.data = data + 1;
926 work.size = 1;
927 doc->md.normal_text(ob, &work, &doc->data);
928 }
929 else hoedown_buffer_putc(ob, data[1]);
930 } else if (size == 1) {
931 hoedown_buffer_putc(ob, data[0]);
932 }
933
934 return 2;
935}
936
937/* char_entity • '&' escaped when it doesn't belong to an entity */
938/* valid entities are assumed to be anything matching &#?[A-Za-z0-9]+; */

Callers

nothing calls this directly

Calls 2

parse_mathFunction · 0.85
hoedown_buffer_putcFunction · 0.85

Tested by

no test coverage detected