Photon 1.0.0
|
#include <assert.h>
#include <ctype.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include "attribute.h"
#include "error.h"
#include "gumbo.h"
#include "insertion_mode.h"
#include "parser.h"
#include "tokenizer.h"
#include "tokenizer_states.h"
#include "utf8.h"
#include "util.h"
#include "vector.h"
Classes | |
struct | _ReplacementEntry |
struct | _NamespacedAttributeReplacement |
struct | _TextNodeBufferState |
struct | GumboInternalParserState |
struct | InsertionLocation |
Macros | |
#define | AVOID_UNUSED_VARIABLE_WARNING(i) (void)(i) |
#define | GUMBO_STRING(literal) { literal, sizeof(literal) - 1 } |
#define | TERMINATOR { "", 0 } |
#define | TAG(tag) [GUMBO_TAG_##tag] = (1 << GUMBO_NAMESPACE_HTML) |
#define | TAG_SVG(tag) [GUMBO_TAG_##tag] = (1 << GUMBO_NAMESPACE_SVG) |
#define | TAG_MATHML(tag) [GUMBO_TAG_##tag] = (1 << GUMBO_NAMESPACE_MATHML) |
#define | TAGSET_INCLUDES(tagset, namespace, tag) (tag < GUMBO_TAG_LAST && tagset[(int) tag] & (1 << (int) namespace)) |
#define | REPLACEMENT_ENTRY(from, to) { GUMBO_STRING(from), GUMBO_STRING(to) } |
Typedefs | |
typedef char | gumbo_tagset[GUMBO_TAG_LAST] |
typedef struct _ReplacementEntry | ReplacementEntry |
typedef struct _NamespacedAttributeReplacement | NamespacedAttributeReplacement |
typedef struct _TextNodeBufferState | TextNodeBufferState |
typedef struct GumboInternalParserState | GumboParserState |
typedef bool(* | TokenHandler) (GumboParser *parser, GumboToken *token) |
Functions | |
InsertionLocation | get_appropriate_insertion_location (GumboParser *parser, GumboNode *override_target) |
void | clear_stack_to_table_body_context (GumboParser *parser) |
GumboNode * | clone_node (GumboParser *parser, GumboNode *node, GumboParseFlags reason) |
const char * | gumbo_normalize_svg_tagname (const GumboStringPiece *tag) |
GumboOutput * | gumbo_parse (const char *buffer) |
GumboOutput * | gumbo_parse_with_options (const GumboOptions *options, const char *buffer, size_t length) |
void | gumbo_destroy_node (GumboOptions *options, GumboNode *node) |
void | gumbo_destroy_output (const GumboOptions *options, GumboOutput *output) |
Variables | |
const GumboOptions | kGumboDefaultOptions |
#define GUMBO_STRING | ( | literal | ) | { literal, sizeof(literal) - 1 } |
#define REPLACEMENT_ENTRY | ( | from, | |
to | |||
) | { GUMBO_STRING(from), GUMBO_STRING(to) } |
#define TAG | ( | tag | ) | [GUMBO_TAG_##tag] = (1 << GUMBO_NAMESPACE_HTML) |
#define TAG_MATHML | ( | tag | ) | [GUMBO_TAG_##tag] = (1 << GUMBO_NAMESPACE_MATHML) |
#define TAG_SVG | ( | tag | ) | [GUMBO_TAG_##tag] = (1 << GUMBO_NAMESPACE_SVG) |
#define TAGSET_INCLUDES | ( | tagset, | |
namespace, | |||
tag | |||
) | (tag < GUMBO_TAG_LAST && tagset[(int) tag] & (1 << (int) namespace)) |
#define TERMINATOR { "", 0 } |
typedef char gumbo_tagset[GUMBO_TAG_LAST] |
typedef struct GumboInternalParserState GumboParserState |
typedef struct _NamespacedAttributeReplacement NamespacedAttributeReplacement |
typedef struct _ReplacementEntry ReplacementEntry |
typedef struct _TextNodeBufferState TextNodeBufferState |
typedef bool(* TokenHandler) (GumboParser *parser, GumboToken *token) |
void clear_stack_to_table_body_context | ( | GumboParser * | parser | ) |
GumboNode * clone_node | ( | GumboParser * | parser, |
GumboNode * | node, | ||
GumboParseFlags | reason | ||
) |
InsertionLocation get_appropriate_insertion_location | ( | GumboParser * | parser, |
GumboNode * | override_target | ||
) |
void gumbo_destroy_node | ( | GumboOptions * | options, |
GumboNode * | node | ||
) |
void gumbo_destroy_output | ( | const GumboOptions * | options, |
GumboOutput * | output | ||
) |
Release the memory used for the parse tree & parse errors.
const char * gumbo_normalize_svg_tagname | ( | const GumboStringPiece * | tagname | ) |
Fixes the case of SVG elements that are not all lowercase. http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#parsing-main-inforeign This is not done at parse time because there's no place to store a mutated tag name. tag_name is an enum (which will be TAG_UNKNOWN for most SVG tags without special handling), while original_tag_name is a pointer into the original buffer. Instead, we provide this helper function that clients can use to rename SVG tags as appropriate. Returns the case-normalized SVG tagname if a replacement is found, or NULL if no normalization is called for. The return value is static data and owned by the library.
GumboOutput * gumbo_parse | ( | const char * | buffer | ) |
Parses a buffer of UTF8 text into an GumboNode parse tree. The buffer must live at least as long as the parse tree, as some fields (eg. original_text) point directly into the original buffer.
This doesn't support buffers longer than 4 gigabytes.
GumboOutput * gumbo_parse_with_options | ( | const GumboOptions * | options, |
const char * | buffer, | ||
size_t | buffer_length | ||
) |
Extended version of gumbo_parse that takes an explicit options structure, buffer, and length.
const GumboOptions kGumboDefaultOptions |
Default options struct; use this with gumbo_parse_with_options.