mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[libdom] Added add_lowercase_to_string
Replace uppercase with lowercase in tag names in html "rewrites"
This commit is contained in:
parent
a9ae51ae9f
commit
abc307e86b
@ -85,3 +85,22 @@ free_document(void *doc)
|
|||||||
dom_node *ddd = (dom_node *)doc;
|
dom_node *ddd = (dom_node *)doc;
|
||||||
dom_node_unref(ddd);
|
dom_node_unref(ddd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
add_lowercase_to_string(struct string *buf, const char *str, int len)
|
||||||
|
{
|
||||||
|
char *tmp = memacpy(str, len);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (!tmp) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
if (tmp[i] >= 'A' && tmp[i] <= 'Z') {
|
||||||
|
tmp[i] += 32;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
add_bytes_to_string(buf, tmp, len);
|
||||||
|
mem_free(tmp);
|
||||||
|
}
|
||||||
|
@ -12,6 +12,7 @@ void *document_parse_text(const char *charset, char *data, size_t length);
|
|||||||
void *document_parse(struct document *document, struct string *source);
|
void *document_parse(struct document *document, struct string *source);
|
||||||
void free_document(void *doc);
|
void free_document(void *doc);
|
||||||
void *el_match_selector(const char *selector, void *node);
|
void *el_match_selector(const char *selector, void *node);
|
||||||
|
void add_lowercase_to_string(struct string *buf, const char *str, int len);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ dump_dom_element_closing(struct string *buf, dom_node *node)
|
|||||||
|
|
||||||
/* Get string data and print element name */
|
/* Get string data and print element name */
|
||||||
add_to_string(buf, "</");
|
add_to_string(buf, "</");
|
||||||
add_bytes_to_string(buf, dom_string_data(node_name), dom_string_byte_length(node_name));
|
add_lowercase_to_string(buf, dom_string_data(node_name), dom_string_byte_length(node_name));
|
||||||
add_char_to_string(buf, '>');
|
add_char_to_string(buf, '>');
|
||||||
|
|
||||||
/* Finished with the node_name dom_string */
|
/* Finished with the node_name dom_string */
|
||||||
@ -146,7 +146,7 @@ dump_dom_element(void *mapa, struct string *buf, dom_node *node, int depth)
|
|||||||
save_in_map(mapa, node, buf->length);
|
save_in_map(mapa, node, buf->length);
|
||||||
|
|
||||||
/* Get string data and print element name */
|
/* Get string data and print element name */
|
||||||
add_bytes_to_string(buf, dom_string_data(node_name), dom_string_byte_length(node_name));
|
add_lowercase_to_string(buf, dom_string_data(node_name), dom_string_byte_length(node_name));
|
||||||
|
|
||||||
exc = dom_node_get_attributes(node, &attrs);
|
exc = dom_node_get_attributes(node, &attrs);
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ dump_dom_element_closing(struct string *buf, dom_node *node)
|
|||||||
|
|
||||||
if (strcmp(dom_string_data(node_name), "BR")) {
|
if (strcmp(dom_string_data(node_name), "BR")) {
|
||||||
add_to_string(buf, "</");
|
add_to_string(buf, "</");
|
||||||
add_bytes_to_string(buf, dom_string_data(node_name), dom_string_byte_length(node_name));
|
add_lowercase_to_string(buf, dom_string_data(node_name), dom_string_byte_length(node_name));
|
||||||
add_char_to_string(buf, '>');
|
add_char_to_string(buf, '>');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ dump_dom_element(void *mapa, void *mapa_rev, struct string *buf, dom_node *node,
|
|||||||
save_offset_in_map(mapa_rev, node, buf->length);
|
save_offset_in_map(mapa_rev, node, buf->length);
|
||||||
|
|
||||||
/* Get string data and print element name */
|
/* Get string data and print element name */
|
||||||
add_bytes_to_string(buf, dom_string_data(node_name), dom_string_byte_length(node_name));
|
add_lowercase_to_string(buf, dom_string_data(node_name), dom_string_byte_length(node_name));
|
||||||
|
|
||||||
if (strcmp(dom_string_data(node_name), "BR") == 0) {
|
if (strcmp(dom_string_data(node_name), "BR") == 0) {
|
||||||
add_char_to_string(buf, '/');
|
add_char_to_string(buf, '/');
|
||||||
|
Loading…
Reference in New Issue
Block a user