HTML-MyHTML
view release on metacpan or search on metacpan
source/myhtml/rules.c view on Meta::CPAN
case MyHTML_TAG_FONT:
case MyHTML_TAG_I:
case MyHTML_TAG_S:
case MyHTML_TAG_SMALL:
case MyHTML_TAG_STRIKE:
case MyHTML_TAG_STRONG:
case MyHTML_TAG_TT:
case MyHTML_TAG_U:
{
myhtml_tree_active_formatting_reconstruction(tree);
myhtml_tree_node_t* current = myhtml_tree_node_insert_html_element(tree, token);
myhtml_tree_active_formatting_append_with_check(tree, current);
break;
}
case MyHTML_TAG_NOBR:
{
myhtml_tree_active_formatting_reconstruction(tree);
if(myhtml_tree_element_in_scope(tree, MyHTML_TAG_NOBR, MyHTML_NAMESPACE_HTML, MyHTML_TAG_CATEGORIES_SCOPE)) {
myhtml_tree_adoption_agency_algorithm(tree, MyHTML_TAG_NOBR);
myhtml_tree_active_formatting_reconstruction(tree);
}
myhtml_tree_node_t* current = myhtml_tree_node_insert_html_element(tree, token);
myhtml_tree_active_formatting_append_with_check(tree, current);
break;
}
case MyHTML_TAG_APPLET:
case MyHTML_TAG_MARQUEE:
case MyHTML_TAG_OBJECT:
{
myhtml_tree_active_formatting_reconstruction(tree);
myhtml_tree_node_insert_html_element(tree, token);
myhtml_tree_active_formatting_append(tree, tree->myhtml->marker); // marker
tree->flags ^= (tree->flags & MyHTML_TREE_FLAGS_FRAMESET_OK);
break;
}
case MyHTML_TAG_TABLE:
{
if((tree->compat_mode & MyHTML_TREE_COMPAT_MODE_QUIRKS) == 0 &&
myhtml_tree_element_in_scope(tree, MyHTML_TAG_P, MyHTML_NAMESPACE_HTML, MyHTML_TAG_CATEGORIES_SCOPE_BUTTON))
{
myhtml_tree_tags_close_p(tree);
}
myhtml_tree_node_insert_html_element(tree, token);
tree->flags ^= (tree->flags & MyHTML_TREE_FLAGS_FRAMESET_OK);
tree->insert_mode = MyHTML_INSERTION_MODE_IN_TABLE;
break;
}
case MyHTML_TAG_AREA:
case MyHTML_TAG_BR:
case MyHTML_TAG_EMBED:
case MyHTML_TAG_IMG:
case MyHTML_TAG_KEYGEN:
case MyHTML_TAG_WBR:
{
myhtml_tree_active_formatting_reconstruction(tree);
myhtml_tree_node_insert_html_element(tree, token);
myhtml_tree_open_elements_pop(tree);
tree->flags ^= (tree->flags & MyHTML_TREE_FLAGS_FRAMESET_OK);
break;
}
case MyHTML_TAG_INPUT:
{
myhtml_tree_active_formatting_reconstruction(tree);
myhtml_tree_node_insert_html_element(tree, token);
myhtml_tree_open_elements_pop(tree);
myhtml_token_node_wait_for_done(token);
if(myhtml_token_attr_match_case(tree->token, token, "type", 4, "hidden", 6) == NULL) {
tree->flags ^= (tree->flags & MyHTML_TREE_FLAGS_FRAMESET_OK);
}
break;
}
case MyHTML_TAG_PARAM:
case MyHTML_TAG_SOURCE:
case MyHTML_TAG_TRACK:
{
myhtml_tree_node_insert_html_element(tree, token);
myhtml_tree_open_elements_pop(tree);
break;
}
case MyHTML_TAG_HR:
{
if(myhtml_tree_element_in_scope(tree, MyHTML_TAG_P, MyHTML_NAMESPACE_HTML, MyHTML_TAG_CATEGORIES_SCOPE_BUTTON)) {
myhtml_tree_tags_close_p(tree);
}
myhtml_tree_node_t* current_node = myhtml_tree_current_node(tree);
if(myhtml_is_html_node(current_node, MyHTML_TAG_MENUITEM))
myhtml_tree_open_elements_pop(tree);
myhtml_tree_node_insert_html_element(tree, token);
myhtml_tree_open_elements_pop(tree);
tree->flags ^= (tree->flags & MyHTML_TREE_FLAGS_FRAMESET_OK);
break;
}
case MyHTML_TAG_IMAGE:
{
token->tag_id = MyHTML_TAG_IMG;
return true;
}
case MyHTML_TAG_TEXTAREA:
{
myhtml_tree_node_insert_html_element(tree, token);
// If the next token is a U+000A LINE FEED (LF) character token,
// then ignore that token and move on to the next one.
// (Newlines at the start of textarea elements are ignored as an authoring convenience.)
// !!! see dispatcher (myhtml_rules_tree_dispatcher) for this
tree->flags |= MyHTML_TREE_FLAGS_PARSE_FLAG|MyHTML_TREE_FLAGS_PARSE_FLAG_EMIT_NEWLINE;
tree->orig_insert_mode = tree->insert_mode;
tree->flags ^= (tree->flags & MyHTML_TREE_FLAGS_FRAMESET_OK);
tree->insert_mode = MyHTML_INSERTION_MODE_TEXT;
tree->state_of_builder = MyHTML_TOKENIZER_STATE_RCDATA;
break;
}
case MyHTML_TAG_XMP:
{
if(myhtml_tree_element_in_scope(tree, MyHTML_TAG_P, MyHTML_NAMESPACE_HTML, MyHTML_TAG_CATEGORIES_SCOPE_BUTTON)) {
myhtml_tree_tags_close_p(tree);
}
myhtml_tree_active_formatting_reconstruction(tree);
tree->flags ^= (tree->flags & MyHTML_TREE_FLAGS_FRAMESET_OK);
tree->state_of_builder = MyHTML_TOKENIZER_STATE_RAWTEXT;
myhtml_tree_generic_raw_text_element_parsing_algorithm(tree, token);
break;
}
case MyHTML_TAG_IFRAME:
{
tree->flags ^= (tree->flags & MyHTML_TREE_FLAGS_FRAMESET_OK);
tree->state_of_builder = MyHTML_TOKENIZER_STATE_RAWTEXT;
myhtml_tree_generic_raw_text_element_parsing_algorithm(tree, token);
break;
}
case MyHTML_TAG_NOEMBED:
{
tree->state_of_builder = MyHTML_TOKENIZER_STATE_RAWTEXT;
myhtml_tree_generic_raw_text_element_parsing_algorithm(tree, token);
break;
}
case MyHTML_TAG_NOSCRIPT:
{
if(tree->flags & MyHTML_TREE_FLAGS_SCRIPT) {
tree->state_of_builder = MyHTML_TOKENIZER_STATE_RAWTEXT;
myhtml_tree_generic_raw_text_element_parsing_algorithm(tree, token);
}
else {
myhtml_tree_active_formatting_reconstruction(tree);
myhtml_tree_node_insert_html_element(tree, token);
}
// else {
// myhtml_tree_node_insert_html_element(tree, token);
// tree->insert_mode = MyHTML_INSERTION_MODE_IN_HEAD_NOSCRIPT;
// }
break;
}
case MyHTML_TAG_SELECT:
{
myhtml_tree_active_formatting_reconstruction(tree);
myhtml_tree_node_insert_html_element(tree, token);
tree->flags ^= (tree->flags & MyHTML_TREE_FLAGS_FRAMESET_OK);
if(tree->insert_mode == MyHTML_INSERTION_MODE_IN_TABLE ||
tree->insert_mode == MyHTML_INSERTION_MODE_IN_CAPTION ||
tree->insert_mode == MyHTML_INSERTION_MODE_IN_TABLE_BODY ||
tree->insert_mode == MyHTML_INSERTION_MODE_IN_ROW ||
tree->insert_mode == MyHTML_INSERTION_MODE_IN_CELL)
{
tree->insert_mode = MyHTML_INSERTION_MODE_IN_SELECT_IN_TABLE;
}
else
tree->insert_mode = MyHTML_INSERTION_MODE_IN_SELECT;
break;
}
case MyHTML_TAG_OPTGROUP:
case MyHTML_TAG_OPTION:
{
myhtml_tree_node_t* current_node = myhtml_tree_current_node(tree);
if(myhtml_is_html_node(current_node, MyHTML_TAG_OPTION))
myhtml_tree_open_elements_pop(tree);
myhtml_tree_active_formatting_reconstruction(tree);
myhtml_tree_node_insert_html_element(tree, token);
break;
}
source/myhtml/rules.c view on Meta::CPAN
myhtml_tree_open_elements_pop(tree);
}
}
return false;
}
bool myhtml_insertion_mode_in_foreign_content(myhtml_tree_t* tree, myhtml_token_node_t* token)
{
if(token->type & MyHTML_TOKEN_TYPE_CLOSE) {
myhtml_tree_node_t* current_node = myhtml_tree_current_node(tree);
if(token->tag_id == MyHTML_TAG_SCRIPT &&
current_node->tag_id == MyHTML_TAG_SCRIPT &&
current_node->ns == MyHTML_NAMESPACE_SVG)
{
myhtml_tree_open_elements_pop(tree);
// TODO: now script is disable, skip this
return false;
}
return myhtml_insertion_mode_in_foreign_content_end_other(tree, current_node, token);
}
else {
switch (token->tag_id)
{
case MyHTML_TAG__TEXT:
{
if(token->type & MyHTML_TOKEN_TYPE_NULL) {
myhtml_token_node_wait_for_done(token);
myhtml_token_set_replacement_character_for_null_token(tree, token);
}
myhtml_tree_node_insert_text(tree, token);
if((token->type & MyHTML_TOKEN_TYPE_WHITESPACE) == 0)
tree->flags ^= (tree->flags & MyHTML_TREE_FLAGS_FRAMESET_OK);
break;
}
case MyHTML_TAG__COMMENT:
myhtml_tree_node_insert_comment(tree, token, NULL);
break;
case MyHTML_TAG__DOCTYPE:
break;
case MyHTML_TAG_B:
case MyHTML_TAG_BIG:
case MyHTML_TAG_BLOCKQUOTE:
case MyHTML_TAG_BODY:
case MyHTML_TAG_BR:
case MyHTML_TAG_CENTER:
case MyHTML_TAG_CODE:
case MyHTML_TAG_DD:
case MyHTML_TAG_DIV:
case MyHTML_TAG_DL:
case MyHTML_TAG_DT:
case MyHTML_TAG_EM:
case MyHTML_TAG_EMBED:
case MyHTML_TAG_H1:
case MyHTML_TAG_H2:
case MyHTML_TAG_H3:
case MyHTML_TAG_H4:
case MyHTML_TAG_H5:
case MyHTML_TAG_H6:
case MyHTML_TAG_HEAD:
case MyHTML_TAG_HR:
case MyHTML_TAG_I:
case MyHTML_TAG_IMG:
case MyHTML_TAG_LI:
case MyHTML_TAG_LISTING:
case MyHTML_TAG_MENU:
case MyHTML_TAG_META:
case MyHTML_TAG_NOBR:
case MyHTML_TAG_OL:
case MyHTML_TAG_P:
case MyHTML_TAG_PRE:
case MyHTML_TAG_RUBY:
case MyHTML_TAG_S:
case MyHTML_TAG_SMALL:
case MyHTML_TAG_SPAN:
case MyHTML_TAG_STRONG:
case MyHTML_TAG_STRIKE:
case MyHTML_TAG_SUB:
case MyHTML_TAG_SUP:
case MyHTML_TAG_TABLE:
case MyHTML_TAG_TT:
case MyHTML_TAG_U:
case MyHTML_TAG_UL:
case MyHTML_TAG_VAR:
case MyHTML_TAG_FONT:
{
// parse error
if(token->tag_id == MyHTML_TAG_FONT)
{
myhtml_token_node_wait_for_done(token);
if(myhtml_token_attr_by_name(token, "color", 5) == NULL &&
myhtml_token_attr_by_name(token, "face" , 4) == NULL &&
myhtml_token_attr_by_name(token, "size" , 4) == NULL)
return myhtml_insertion_mode_in_foreign_content_start_other(tree, token);
}
if(tree->fragment == NULL) {
myhtml_tree_node_t* current_node;
do {
myhtml_tree_open_elements_pop(tree);
current_node = myhtml_tree_current_node(tree);
}
while(current_node && !(myhtml_tree_is_mathml_integration_point(tree, current_node) ||
myhtml_tree_is_html_integration_point(tree, current_node) ||
current_node->ns == MyHTML_NAMESPACE_HTML));
return true;
}
}
default:
( run in 1.171 second using v1.01-cache-2.11-cpan-71847e10f99 )