Hubbub $Id$
|
#include <assert.h>
#include <string.h>
#include <strings.h>
#include <stdio.h>
#include "treebuilder/modes.h"
#include "treebuilder/internal.h"
#include "treebuilder/treebuilder.h"
#include "utils/utils.h"
Macros | |
#define | mode(x) |
Functions | |
hubbub_error | hubbub_treebuilder_create (hubbub_tokeniser *tokeniser, hubbub_treebuilder **treebuilder) |
Create a hubbub treebuilder. More... | |
hubbub_error | hubbub_treebuilder_destroy (hubbub_treebuilder *treebuilder) |
Destroy a hubbub treebuilder. More... | |
hubbub_error | hubbub_treebuilder_setopt (hubbub_treebuilder *treebuilder, hubbub_treebuilder_opttype type, hubbub_treebuilder_optparams *params) |
Configure a hubbub treebuilder. More... | |
hubbub_error | hubbub_treebuilder_token_handler (const hubbub_token *token, void *pw) |
Handle tokeniser emitting a token. More... | |
hubbub_error | process_characters_expect_whitespace (hubbub_treebuilder *treebuilder, const hubbub_token *token, bool insert_into_current_node) |
Process a character token in cases where we expect only whitespace. More... | |
hubbub_error | process_comment_append (hubbub_treebuilder *treebuilder, const hubbub_token *token, void *parent) |
Process a comment token, appending it to the given parent. More... | |
hubbub_error | parse_generic_rcdata (hubbub_treebuilder *treebuilder, const hubbub_token *token, bool rcdata) |
Trigger parsing of generic (R)CDATA. More... | |
uint32_t | element_in_scope (hubbub_treebuilder *treebuilder, element_type type, bool in_table) |
Determine if an element is in (table) scope. More... | |
hubbub_error | reconstruct_active_formatting_list (hubbub_treebuilder *treebuilder) |
Reconstruct the list of active formatting elements. More... | |
hubbub_error | remove_node_from_dom (hubbub_treebuilder *treebuilder, void *node) |
Remove a node from the DOM. More... | |
void | clear_active_formatting_list_to_marker (hubbub_treebuilder *treebuilder) |
Clear the list of active formatting elements up to the last marker. More... | |
hubbub_error | insert_element (hubbub_treebuilder *treebuilder, const hubbub_tag *tag, bool push) |
Create element and insert it into the DOM, potentially pushing it on the stack. More... | |
void | close_implied_end_tags (hubbub_treebuilder *treebuilder, element_type except) |
Close implied end tags. More... | |
void | reset_insertion_mode (hubbub_treebuilder *treebuilder) |
Reset the insertion mode. More... | |
hubbub_error | complete_script (hubbub_treebuilder *treebuilder) |
Script processing and execution. More... | |
hubbub_error | append_text (hubbub_treebuilder *treebuilder, const hubbub_string *string) |
Append text to the current node, inserting into the last child of the current node, iff it's a Text node. More... | |
bool | is_special_element (element_type type) |
Determine if a node is a special element. More... | |
bool | is_scoping_element (element_type type) |
Determine if a node is a scoping element. More... | |
bool | is_formatting_element (element_type type) |
Determine if a node is a formatting element. More... | |
bool | is_phrasing_element (element_type type) |
Determine if a node is a phrasing element. More... | |
hubbub_error | element_stack_push (hubbub_treebuilder *treebuilder, hubbub_ns ns, element_type type, void *node) |
Push an element onto the stack of open elements. More... | |
hubbub_error | element_stack_pop (hubbub_treebuilder *treebuilder, hubbub_ns *ns, element_type *type, void **node) |
Pop an element off the stack of open elements. More... | |
hubbub_error | element_stack_pop_until (hubbub_treebuilder *treebuilder, element_type type) |
Pop elements until an element of type "element" has been popped. More... | |
hubbub_error | element_stack_remove (hubbub_treebuilder *treebuilder, uint32_t index, hubbub_ns *ns, element_type *type, void **removed) |
Remove a node from the stack of open elements. More... | |
uint32_t | current_table (hubbub_treebuilder *treebuilder) |
Find the stack index of the current table. More... | |
element_type | current_node (hubbub_treebuilder *treebuilder) |
Peek at the top element of the element stack. More... | |
element_type | prev_node (hubbub_treebuilder *treebuilder) |
Peek at the element below the top of the element stack. More... | |
hubbub_error | formatting_list_append (hubbub_treebuilder *treebuilder, hubbub_ns ns, element_type type, void *node, uint32_t stack_index) |
Append an element to the end of the list of active formatting elements. More... | |
hubbub_error | formatting_list_insert (hubbub_treebuilder *treebuilder, formatting_list_entry *prev, formatting_list_entry *next, hubbub_ns ns, element_type type, void *node, uint32_t stack_index) |
Insert an element into the list of active formatting elements. More... | |
hubbub_error | formatting_list_remove (hubbub_treebuilder *treebuilder, formatting_list_entry *entry, hubbub_ns *ns, element_type *type, void **node, uint32_t *stack_index) |
Remove an element from the list of active formatting elements. More... | |
hubbub_error | formatting_list_replace (hubbub_treebuilder *treebuilder, formatting_list_entry *entry, hubbub_ns ns, element_type type, void *node, uint32_t stack_index, hubbub_ns *ons, element_type *otype, void **onode, uint32_t *ostack_index) |
Remove an element from the list of active formatting elements. More... | |
void | element_stack_dump (hubbub_treebuilder *treebuilder, FILE *fp) |
Dump an element stack to the given file pointer. More... | |
void | formatting_list_dump (hubbub_treebuilder *treebuilder, FILE *fp) |
Dump a formatting list to the given file pointer. More... | |
#define mode | ( | x | ) |
hubbub_error append_text | ( | hubbub_treebuilder * | treebuilder, |
const hubbub_string * | string | ||
) |
Append text to the current node, inserting into the last child of the current node, iff it's a Text node.
treebuilder | The treebuilder instance |
string | The string to append |
void clear_active_formatting_list_to_marker | ( | hubbub_treebuilder * | treebuilder | ) |
Clear the list of active formatting elements up to the last marker.
treebuilder | The treebuilder instance containing the list |
void close_implied_end_tags | ( | hubbub_treebuilder * | treebuilder, |
element_type | except | ||
) |
Close implied end tags.
treebuilder | The treebuilder instance |
except | Tag type to exclude from processing [DD,DT,LI,OPTION, OPTGROUP,P,RP,RT], UNKNOWN to exclude nothing |
hubbub_error complete_script | ( | hubbub_treebuilder * | treebuilder | ) |
Script processing and execution.
treebuilder | The treebuilder instance |
element_type current_node | ( | hubbub_treebuilder * | treebuilder | ) |
Peek at the top element of the element stack.
treebuilder | Treebuilder instance |
uint32_t current_table | ( | hubbub_treebuilder * | treebuilder | ) |
Find the stack index of the current table.
uint32_t element_in_scope | ( | hubbub_treebuilder * | treebuilder, |
element_type | type, | ||
bool | in_table | ||
) |
Determine if an element is in (table) scope.
treebuilder | Treebuilder to look in |
type | Element type to find |
in_table | Whether we're looking in table scope |
void element_stack_dump | ( | hubbub_treebuilder * | treebuilder, |
FILE * | fp | ||
) |
Dump an element stack to the given file pointer.
treebuilder | The treebuilder instance |
fp | The file to dump to |
hubbub_error element_stack_pop | ( | hubbub_treebuilder * | treebuilder, |
hubbub_ns * | ns, | ||
element_type * | type, | ||
void ** | node | ||
) |
Pop an element off the stack of open elements.
treebuilder | The treebuilder instance containing the stack |
ns | Pointer to location to receive element namespace |
type | Pointer to location to receive element type |
node | Pointer to location to receive node |
hubbub_error element_stack_pop_until | ( | hubbub_treebuilder * | treebuilder, |
element_type | type | ||
) |
Pop elements until an element of type "element" has been popped.
hubbub_error element_stack_push | ( | hubbub_treebuilder * | treebuilder, |
hubbub_ns | ns, | ||
element_type | type, | ||
void * | node | ||
) |
Push an element onto the stack of open elements.
treebuilder | The treebuilder instance containing the stack |
ns | The namespace of element being pushed |
type | The type of element being pushed |
node | The node to push |
hubbub_error element_stack_remove | ( | hubbub_treebuilder * | treebuilder, |
uint32_t | index, | ||
hubbub_ns * | ns, | ||
element_type * | type, | ||
void ** | removed | ||
) |
Remove a node from the stack of open elements.
treebuilder | The treebuilder instance |
index | The index of the node to remove |
ns | Pointer to location to receive namespace |
type | Pointer to location to receive type |
removed | Pointer to location to receive removed node |
hubbub_error formatting_list_append | ( | hubbub_treebuilder * | treebuilder, |
hubbub_ns | ns, | ||
element_type | type, | ||
void * | node, | ||
uint32_t | stack_index | ||
) |
Append an element to the end of the list of active formatting elements.
treebuilder | Treebuilder instance containing list |
ns | Namespace of node being inserted |
type | Type of node being inserted |
node | Node being inserted |
stack_index | Index into stack of open elements |
void formatting_list_dump | ( | hubbub_treebuilder * | treebuilder, |
FILE * | fp | ||
) |
Dump a formatting list to the given file pointer.
treebuilder | The treebuilder instance |
fp | The file to dump to |
hubbub_error formatting_list_insert | ( | hubbub_treebuilder * | treebuilder, |
formatting_list_entry * | prev, | ||
formatting_list_entry * | next, | ||
hubbub_ns | ns, | ||
element_type | type, | ||
void * | node, | ||
uint32_t | stack_index | ||
) |
Insert an element into the list of active formatting elements.
treebuilder | Treebuilder instance containing list |
prev | Previous entry |
next | Next entry |
ns | Namespace of node being inserted |
type | Type of node being inserted |
node | Node being inserted |
stack_index | Index into stack of open elements |
hubbub_error formatting_list_remove | ( | hubbub_treebuilder * | treebuilder, |
formatting_list_entry * | entry, | ||
hubbub_ns * | ns, | ||
element_type * | type, | ||
void ** | node, | ||
uint32_t * | stack_index | ||
) |
Remove an element from the list of active formatting elements.
treebuilder | Treebuilder instance containing list |
entry | The item to remove |
ns | Pointer to location to receive namespace of node |
type | Pointer to location to receive type of node |
node | Pointer to location to receive node |
stack_index | Pointer to location to receive stack index |
hubbub_error formatting_list_replace | ( | hubbub_treebuilder * | treebuilder, |
formatting_list_entry * | entry, | ||
hubbub_ns | ns, | ||
element_type | type, | ||
void * | node, | ||
uint32_t | stack_index, | ||
hubbub_ns * | ons, | ||
element_type * | otype, | ||
void ** | onode, | ||
uint32_t * | ostack_index | ||
) |
Remove an element from the list of active formatting elements.
treebuilder | Treebuilder instance containing list |
entry | The item to replace |
ns | Replacement node namespace |
type | Replacement node type |
node | Replacement node |
stack_index | Replacement stack index |
ons | Pointer to location to receive old namespace |
otype | Pointer to location to receive old type |
onode | Pointer to location to receive old node |
ostack_index | Pointer to location to receive old stack index |
hubbub_error hubbub_treebuilder_create | ( | hubbub_tokeniser * | tokeniser, |
hubbub_treebuilder ** | treebuilder | ||
) |
Create a hubbub treebuilder.
tokeniser | Underlying tokeniser instance |
treebuilder | Pointer to location to receive treebuilder instance |
hubbub_error hubbub_treebuilder_destroy | ( | hubbub_treebuilder * | treebuilder | ) |
Destroy a hubbub treebuilder.
treebuilder | The treebuilder instance to destroy |
hubbub_error hubbub_treebuilder_setopt | ( | hubbub_treebuilder * | treebuilder, |
hubbub_treebuilder_opttype | type, | ||
hubbub_treebuilder_optparams * | params | ||
) |
Configure a hubbub treebuilder.
treebuilder | The treebuilder instance to configure |
type | The option type to configure |
params | Pointer to option-specific parameters |
hubbub_error hubbub_treebuilder_token_handler | ( | const hubbub_token * | token, |
void * | pw | ||
) |
Handle tokeniser emitting a token.
token | The emitted token |
pw | Pointer to treebuilder instance |
hubbub_error insert_element | ( | hubbub_treebuilder * | treebuilder, |
const hubbub_tag * | tag, | ||
bool | push | ||
) |
Create element and insert it into the DOM, potentially pushing it on the stack.
treebuilder | The treebuilder instance |
tag | The element to insert |
push | Whether to push the element onto the stack |
bool is_formatting_element | ( | element_type | type | ) |
Determine if a node is a formatting element.
type | Node type to consider |
bool is_phrasing_element | ( | element_type | type | ) |
Determine if a node is a phrasing element.
type | Node type to consider |
bool is_scoping_element | ( | element_type | type | ) |
Determine if a node is a scoping element.
type | Node type to consider |
bool is_special_element | ( | element_type | type | ) |
Determine if a node is a special element.
type | Node type to consider |
hubbub_error parse_generic_rcdata | ( | hubbub_treebuilder * | treebuilder, |
const hubbub_token * | token, | ||
bool | rcdata | ||
) |
Trigger parsing of generic (R)CDATA.
treebuilder | The treebuilder instance |
token | The current token |
rcdata | True for RCDATA, false for CDATA |
element_type prev_node | ( | hubbub_treebuilder * | treebuilder | ) |
Peek at the element below the top of the element stack.
treebuilder | Treebuilder instance |
hubbub_error process_characters_expect_whitespace | ( | hubbub_treebuilder * | treebuilder, |
const hubbub_token * | token, | ||
bool | insert_into_current_node | ||
) |
Process a character token in cases where we expect only whitespace.
treebuilder | The treebuilder instance |
token | The character token |
insert_into_current_node | Whether to insert whitespace into current node |
hubbub_error process_comment_append | ( | hubbub_treebuilder * | treebuilder, |
const hubbub_token * | token, | ||
void * | parent | ||
) |
Process a comment token, appending it to the given parent.
treebuilder | The treebuilder instance |
token | The comment token |
parent | The node to append to |
hubbub_error reconstruct_active_formatting_list | ( | hubbub_treebuilder * | treebuilder | ) |
Reconstruct the list of active formatting elements.
treebuilder | Treebuilder instance containing list |
hubbub_error remove_node_from_dom | ( | hubbub_treebuilder * | treebuilder, |
void * | node | ||
) |
Remove a node from the DOM.
treebuilder | Treebuilder instance |
node | Node to remove |
void reset_insertion_mode | ( | hubbub_treebuilder * | treebuilder | ) |
Reset the insertion mode.
treebuilder | The treebuilder to reset |