MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / rs_md_html_start

Function rs_md_html_start

internal/cbm/doclink_rs.c:1040–1081  ·  view source on GitHub ↗

The HTML block that starts at the cursor (RS_HTML_*), none inside a * paragraph for the kind that cannot interrupt one. */

Source from the content-addressed store, hash-verified

1038/* The HTML block that starts at the cursor (RS_HTML_*), none inside a
1039 * paragraph for the kind that cannot interrupt one. */
1040static int rs_md_html_start(const rs_cur_t *c, bool in_para) {
1041 const char *p = c->p + c->pos;
1042 uint32_t n = c->n - c->pos;
1043 if (n < PAIR_LEN || p[0] != '<') {
1044 return RS_HTML_NONE;
1045 }
1046 static const char *const raw[] = {"<pre", "<script", "<style", "<textarea"};
1047 for (size_t i = 0; i < sizeof(raw) / sizeof(raw[0]); i++) {
1048 size_t rl = strlen(raw[i]);
1049 if (rs_ci_prefix(p, n, raw[i]) &&
1050 (n == rl || p[rl] == ' ' || p[rl] == '\t' || p[rl] == '>' || p[rl] == '\r')) {
1051 return RS_HTML_RAW;
1052 }
1053 }
1054 if (rs_ci_prefix(p, n, "<!--")) {
1055 return RS_HTML_COMMENT;
1056 }
1057 if (p[1] == '?') {
1058 return RS_HTML_PI;
1059 }
1060 if (rs_ci_prefix(p, n, "<![cdata[")) {
1061 return RS_HTML_CDATA;
1062 }
1063 if (p[1] == '!' && n > PAIR_LEN && isalpha((unsigned char)p[PAIR_LEN])) {
1064 return RS_HTML_DECL;
1065 }
1066 uint32_t k = p[1] == '/' ? PAIR_LEN : SKIP_ONE;
1067 uint32_t name = k;
1068 while (k < n && (isalnum((unsigned char)p[k]) || p[k] == '-')) {
1069 k++;
1070 }
1071 if (k == name || !isalpha((unsigned char)p[name])) {
1072 return RS_HTML_NONE;
1073 }
1074 bool ends = k >= n || p[k] == ' ' || p[k] == '\t' || p[k] == '>' || p[k] == '\r' ||
1075 (p[k] == '/' && k + SKIP_ONE < n && p[k + SKIP_ONE] == '>');
1076 if (ends && rs_html_block_tag(p + name, k - name)) {
1077 return RS_HTML_BLOCK;
1078 }
1079 uint32_t end = rs_html_tag_end(p, n);
1080 return (!in_para && end > 0 && rs_blank(p + end, n - end)) ? RS_HTML_ANY : RS_HTML_NONE;
1081}
1082
1083/* True when this line ends the open HTML block of kind `html`. */
1084static bool rs_md_html_end(const rs_line_t *ln, int html) {

Callers 1

rs_md_block_atFunction · 0.85

Calls 4

rs_ci_prefixFunction · 0.85
rs_html_block_tagFunction · 0.85
rs_html_tag_endFunction · 0.85
rs_blankFunction · 0.85

Tested by

no test coverage detected