Blame include/libxml/HTMLparser.h

Packit 423ecb
/*
Packit 423ecb
 * Summary: interface for an HTML 4.0 non-verifying parser
Packit 423ecb
 * Description: this module implements an HTML 4.0 non-verifying parser
Packit 423ecb
 *              with API compatible with the XML parser ones. It should
Packit 423ecb
 *              be able to parse "real world" HTML, even if severely
Packit 423ecb
 *              broken from a specification point of view.
Packit 423ecb
 *
Packit 423ecb
 * Copy: See Copyright for the status of this software.
Packit 423ecb
 *
Packit 423ecb
 * Author: Daniel Veillard
Packit 423ecb
 */
Packit 423ecb
Packit 423ecb
#ifndef __HTML_PARSER_H__
Packit 423ecb
#define __HTML_PARSER_H__
Packit 423ecb
#include <libxml/xmlversion.h>
Packit 423ecb
#include <libxml/parser.h>
Packit 423ecb
Packit 423ecb
#ifdef LIBXML_HTML_ENABLED
Packit 423ecb
Packit 423ecb
#ifdef __cplusplus
Packit 423ecb
extern "C" {
Packit 423ecb
#endif
Packit 423ecb
Packit 423ecb
/*
Packit 423ecb
 * Most of the back-end structures from XML and HTML are shared.
Packit 423ecb
 */
Packit 423ecb
typedef xmlParserCtxt htmlParserCtxt;
Packit 423ecb
typedef xmlParserCtxtPtr htmlParserCtxtPtr;
Packit 423ecb
typedef xmlParserNodeInfo htmlParserNodeInfo;
Packit 423ecb
typedef xmlSAXHandler htmlSAXHandler;
Packit 423ecb
typedef xmlSAXHandlerPtr htmlSAXHandlerPtr;
Packit 423ecb
typedef xmlParserInput htmlParserInput;
Packit 423ecb
typedef xmlParserInputPtr htmlParserInputPtr;
Packit 423ecb
typedef xmlDocPtr htmlDocPtr;
Packit 423ecb
typedef xmlNodePtr htmlNodePtr;
Packit 423ecb
Packit 423ecb
/*
Packit 423ecb
 * Internal description of an HTML element, representing HTML 4.01
Packit 423ecb
 * and XHTML 1.0 (which share the same structure).
Packit 423ecb
 */
Packit 423ecb
typedef struct _htmlElemDesc htmlElemDesc;
Packit 423ecb
typedef htmlElemDesc *htmlElemDescPtr;
Packit 423ecb
struct _htmlElemDesc {
Packit 423ecb
    const char *name;	/* The tag name */
Packit 423ecb
    char startTag;      /* Whether the start tag can be implied */
Packit 423ecb
    char endTag;        /* Whether the end tag can be implied */
Packit 423ecb
    char saveEndTag;    /* Whether the end tag should be saved */
Packit 423ecb
    char empty;         /* Is this an empty element ? */
Packit 423ecb
    char depr;          /* Is this a deprecated element ? */
Packit 423ecb
    char dtd;           /* 1: only in Loose DTD, 2: only Frameset one */
Packit 423ecb
    char isinline;      /* is this a block 0 or inline 1 element */
Packit 423ecb
    const char *desc;   /* the description */
Packit 423ecb
Packit 423ecb
/* NRK Jan.2003
Packit 423ecb
 * New fields encapsulating HTML structure
Packit 423ecb
 *
Packit 423ecb
 * Bugs:
Packit 423ecb
 *	This is a very limited representation.  It fails to tell us when
Packit 423ecb
 *	an element *requires* subelements (we only have whether they're
Packit 423ecb
 *	allowed or not), and it doesn't tell us where CDATA and PCDATA
Packit 423ecb
 *	are allowed.  Some element relationships are not fully represented:
Packit 423ecb
 *	these are flagged with the word MODIFIER
Packit 423ecb
 */
Packit 423ecb
    const char** subelts;		/* allowed sub-elements of this element */
Packit 423ecb
    const char* defaultsubelt;	/* subelement for suggested auto-repair
Packit 423ecb
					   if necessary or NULL */
Packit 423ecb
    const char** attrs_opt;		/* Optional Attributes */
Packit 423ecb
    const char** attrs_depr;		/* Additional deprecated attributes */
Packit 423ecb
    const char** attrs_req;		/* Required attributes */
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
/*
Packit 423ecb
 * Internal description of an HTML entity.
Packit 423ecb
 */
Packit 423ecb
typedef struct _htmlEntityDesc htmlEntityDesc;
Packit 423ecb
typedef htmlEntityDesc *htmlEntityDescPtr;
Packit 423ecb
struct _htmlEntityDesc {
Packit 423ecb
    unsigned int value;	/* the UNICODE value for the character */
Packit 423ecb
    const char *name;	/* The entity name */
Packit 423ecb
    const char *desc;   /* the description */
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
/*
Packit 423ecb
 * There is only few public functions.
Packit 423ecb
 */
Packit 423ecb
XMLPUBFUN const htmlElemDesc * XMLCALL
Packit 423ecb
			htmlTagLookup	(const xmlChar *tag);
Packit 423ecb
XMLPUBFUN const htmlEntityDesc * XMLCALL
Packit 423ecb
			htmlEntityLookup(const xmlChar *name);
Packit 423ecb
XMLPUBFUN const htmlEntityDesc * XMLCALL
Packit 423ecb
			htmlEntityValueLookup(unsigned int value);
Packit 423ecb
Packit 423ecb
XMLPUBFUN int XMLCALL
Packit 423ecb
			htmlIsAutoClosed(htmlDocPtr doc,
Packit 423ecb
					 htmlNodePtr elem);
Packit 423ecb
XMLPUBFUN int XMLCALL
Packit 423ecb
			htmlAutoCloseTag(htmlDocPtr doc,
Packit 423ecb
					 const xmlChar *name,
Packit 423ecb
					 htmlNodePtr elem);
Packit 423ecb
XMLPUBFUN const htmlEntityDesc * XMLCALL
Packit 423ecb
			htmlParseEntityRef(htmlParserCtxtPtr ctxt,
Packit 423ecb
					 const xmlChar **str);
Packit 423ecb
XMLPUBFUN int XMLCALL
Packit 423ecb
			htmlParseCharRef(htmlParserCtxtPtr ctxt);
Packit 423ecb
XMLPUBFUN void XMLCALL
Packit 423ecb
			htmlParseElement(htmlParserCtxtPtr ctxt);
Packit 423ecb
Packit 423ecb
XMLPUBFUN htmlParserCtxtPtr XMLCALL
Packit 423ecb
			htmlNewParserCtxt(void);
Packit 423ecb
Packit 423ecb
XMLPUBFUN htmlParserCtxtPtr XMLCALL
Packit 423ecb
			htmlCreateMemoryParserCtxt(const char *buffer,
Packit 423ecb
						   int size);
Packit 423ecb
Packit 423ecb
XMLPUBFUN int XMLCALL
Packit 423ecb
			htmlParseDocument(htmlParserCtxtPtr ctxt);
Packit 423ecb
XMLPUBFUN htmlDocPtr XMLCALL
Packit 423ecb
			htmlSAXParseDoc	(const xmlChar *cur,
Packit 423ecb
					 const char *encoding,
Packit 423ecb
					 htmlSAXHandlerPtr sax,
Packit 423ecb
					 void *userData);
Packit 423ecb
XMLPUBFUN htmlDocPtr XMLCALL
Packit 423ecb
			htmlParseDoc	(const xmlChar *cur,
Packit 423ecb
					 const char *encoding);
Packit 423ecb
XMLPUBFUN htmlDocPtr XMLCALL
Packit 423ecb
			htmlSAXParseFile(const char *filename,
Packit 423ecb
					 const char *encoding,
Packit 423ecb
					 htmlSAXHandlerPtr sax,
Packit 423ecb
					 void *userData);
Packit 423ecb
XMLPUBFUN htmlDocPtr XMLCALL
Packit 423ecb
			htmlParseFile	(const char *filename,
Packit 423ecb
					 const char *encoding);
Packit 423ecb
XMLPUBFUN int XMLCALL
Packit 423ecb
			UTF8ToHtml	(unsigned char *out,
Packit 423ecb
					 int *outlen,
Packit 423ecb
					 const unsigned char *in,
Packit 423ecb
					 int *inlen);
Packit 423ecb
XMLPUBFUN int XMLCALL
Packit 423ecb
			htmlEncodeEntities(unsigned char *out,
Packit 423ecb
					 int *outlen,
Packit 423ecb
					 const unsigned char *in,
Packit 423ecb
					 int *inlen, int quoteChar);
Packit 423ecb
XMLPUBFUN int XMLCALL
Packit 423ecb
			htmlIsScriptAttribute(const xmlChar *name);
Packit 423ecb
XMLPUBFUN int XMLCALL
Packit 423ecb
			htmlHandleOmittedElem(int val);
Packit 423ecb
Packit 423ecb
#ifdef LIBXML_PUSH_ENABLED
Packit 423ecb
/**
Packit 423ecb
 * Interfaces for the Push mode.
Packit 423ecb
 */
Packit 423ecb
XMLPUBFUN htmlParserCtxtPtr XMLCALL
Packit 423ecb
			htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax,
Packit 423ecb
						 void *user_data,
Packit 423ecb
						 const char *chunk,
Packit 423ecb
						 int size,
Packit 423ecb
						 const char *filename,
Packit 423ecb
						 xmlCharEncoding enc);
Packit 423ecb
XMLPUBFUN int XMLCALL
Packit 423ecb
			htmlParseChunk		(htmlParserCtxtPtr ctxt,
Packit 423ecb
						 const char *chunk,
Packit 423ecb
						 int size,
Packit 423ecb
						 int terminate);
Packit 423ecb
#endif /* LIBXML_PUSH_ENABLED */
Packit 423ecb
Packit 423ecb
XMLPUBFUN void XMLCALL
Packit 423ecb
			htmlFreeParserCtxt	(htmlParserCtxtPtr ctxt);
Packit 423ecb
Packit 423ecb
/*
Packit 423ecb
 * New set of simpler/more flexible APIs
Packit 423ecb
 */
Packit 423ecb
/**
Packit 423ecb
 * xmlParserOption:
Packit 423ecb
 *
Packit 423ecb
 * This is the set of XML parser options that can be passed down
Packit 423ecb
 * to the xmlReadDoc() and similar calls.
Packit 423ecb
 */
Packit 423ecb
typedef enum {
Packit 423ecb
    HTML_PARSE_RECOVER  = 1<<0, /* Relaxed parsing */
Packit 423ecb
    HTML_PARSE_NODEFDTD = 1<<2, /* do not default a doctype if not found */
Packit 423ecb
    HTML_PARSE_NOERROR	= 1<<5,	/* suppress error reports */
Packit 423ecb
    HTML_PARSE_NOWARNING= 1<<6,	/* suppress warning reports */
Packit 423ecb
    HTML_PARSE_PEDANTIC	= 1<<7,	/* pedantic error reporting */
Packit 423ecb
    HTML_PARSE_NOBLANKS	= 1<<8,	/* remove blank nodes */
Packit 423ecb
    HTML_PARSE_NONET	= 1<<11,/* Forbid network access */
Packit 423ecb
    HTML_PARSE_NOIMPLIED= 1<<13,/* Do not add implied html/body... elements */
Packit 423ecb
    HTML_PARSE_COMPACT  = 1<<16,/* compact small text nodes */
Packit 423ecb
    HTML_PARSE_IGNORE_ENC=1<<21 /* ignore internal document encoding hint */
Packit 423ecb
} htmlParserOption;
Packit 423ecb
Packit 423ecb
XMLPUBFUN void XMLCALL
Packit 423ecb
		htmlCtxtReset		(htmlParserCtxtPtr ctxt);
Packit 423ecb
XMLPUBFUN int XMLCALL
Packit 423ecb
		htmlCtxtUseOptions	(htmlParserCtxtPtr ctxt,
Packit 423ecb
					 int options);
Packit 423ecb
XMLPUBFUN htmlDocPtr XMLCALL
Packit 423ecb
		htmlReadDoc		(const xmlChar *cur,
Packit 423ecb
					 const char *URL,
Packit 423ecb
					 const char *encoding,
Packit 423ecb
					 int options);
Packit 423ecb
XMLPUBFUN htmlDocPtr XMLCALL
Packit 423ecb
		htmlReadFile		(const char *URL,
Packit 423ecb
					 const char *encoding,
Packit 423ecb
					 int options);
Packit 423ecb
XMLPUBFUN htmlDocPtr XMLCALL
Packit 423ecb
		htmlReadMemory		(const char *buffer,
Packit 423ecb
					 int size,
Packit 423ecb
					 const char *URL,
Packit 423ecb
					 const char *encoding,
Packit 423ecb
					 int options);
Packit 423ecb
XMLPUBFUN htmlDocPtr XMLCALL
Packit 423ecb
		htmlReadFd		(int fd,
Packit 423ecb
					 const char *URL,
Packit 423ecb
					 const char *encoding,
Packit 423ecb
					 int options);
Packit 423ecb
XMLPUBFUN htmlDocPtr XMLCALL
Packit 423ecb
		htmlReadIO		(xmlInputReadCallback ioread,
Packit 423ecb
					 xmlInputCloseCallback ioclose,
Packit 423ecb
					 void *ioctx,
Packit 423ecb
					 const char *URL,
Packit 423ecb
					 const char *encoding,
Packit 423ecb
					 int options);
Packit 423ecb
XMLPUBFUN htmlDocPtr XMLCALL
Packit 423ecb
		htmlCtxtReadDoc		(xmlParserCtxtPtr ctxt,
Packit 423ecb
					 const xmlChar *cur,
Packit 423ecb
					 const char *URL,
Packit 423ecb
					 const char *encoding,
Packit 423ecb
					 int options);
Packit 423ecb
XMLPUBFUN htmlDocPtr XMLCALL
Packit 423ecb
		htmlCtxtReadFile		(xmlParserCtxtPtr ctxt,
Packit 423ecb
					 const char *filename,
Packit 423ecb
					 const char *encoding,
Packit 423ecb
					 int options);
Packit 423ecb
XMLPUBFUN htmlDocPtr XMLCALL
Packit 423ecb
		htmlCtxtReadMemory		(xmlParserCtxtPtr ctxt,
Packit 423ecb
					 const char *buffer,
Packit 423ecb
					 int size,
Packit 423ecb
					 const char *URL,
Packit 423ecb
					 const char *encoding,
Packit 423ecb
					 int options);
Packit 423ecb
XMLPUBFUN htmlDocPtr XMLCALL
Packit 423ecb
		htmlCtxtReadFd		(xmlParserCtxtPtr ctxt,
Packit 423ecb
					 int fd,
Packit 423ecb
					 const char *URL,
Packit 423ecb
					 const char *encoding,
Packit 423ecb
					 int options);
Packit 423ecb
XMLPUBFUN htmlDocPtr XMLCALL
Packit 423ecb
		htmlCtxtReadIO		(xmlParserCtxtPtr ctxt,
Packit 423ecb
					 xmlInputReadCallback ioread,
Packit 423ecb
					 xmlInputCloseCallback ioclose,
Packit 423ecb
					 void *ioctx,
Packit 423ecb
					 const char *URL,
Packit 423ecb
					 const char *encoding,
Packit 423ecb
					 int options);
Packit 423ecb
Packit 423ecb
/* NRK/Jan2003: further knowledge of HTML structure
Packit 423ecb
 */
Packit 423ecb
typedef enum {
Packit 423ecb
  HTML_NA = 0 ,		/* something we don't check at all */
Packit 423ecb
  HTML_INVALID = 0x1 ,
Packit 423ecb
  HTML_DEPRECATED = 0x2 ,
Packit 423ecb
  HTML_VALID = 0x4 ,
Packit 423ecb
  HTML_REQUIRED = 0xc /* VALID bit set so ( & HTML_VALID ) is TRUE */
Packit 423ecb
} htmlStatus ;
Packit 423ecb
Packit 423ecb
/* Using htmlElemDesc rather than name here, to emphasise the fact
Packit 423ecb
   that otherwise there's a lookup overhead
Packit 423ecb
*/
Packit 423ecb
XMLPUBFUN htmlStatus XMLCALL htmlAttrAllowed(const htmlElemDesc*, const xmlChar*, int) ;
Packit 423ecb
XMLPUBFUN int XMLCALL htmlElementAllowedHere(const htmlElemDesc*, const xmlChar*) ;
Packit 423ecb
XMLPUBFUN htmlStatus XMLCALL htmlElementStatusHere(const htmlElemDesc*, const htmlElemDesc*) ;
Packit 423ecb
XMLPUBFUN htmlStatus XMLCALL htmlNodeStatus(const htmlNodePtr, int) ;
Packit 423ecb
/**
Packit 423ecb
 * htmlDefaultSubelement:
Packit 423ecb
 * @elt: HTML element
Packit 423ecb
 *
Packit 423ecb
 * Returns the default subelement for this element
Packit 423ecb
 */
Packit 423ecb
#define htmlDefaultSubelement(elt) elt->defaultsubelt
Packit 423ecb
/**
Packit 423ecb
 * htmlElementAllowedHereDesc:
Packit 423ecb
 * @parent: HTML parent element
Packit 423ecb
 * @elt: HTML element
Packit 423ecb
 *
Packit 423ecb
 * Checks whether an HTML element description may be a
Packit 423ecb
 * direct child of the specified element.
Packit 423ecb
 *
Packit 423ecb
 * Returns 1 if allowed; 0 otherwise.
Packit 423ecb
 */
Packit 423ecb
#define htmlElementAllowedHereDesc(parent,elt) \
Packit 423ecb
	htmlElementAllowedHere((parent), (elt)->name)
Packit 423ecb
/**
Packit 423ecb
 * htmlRequiredAttrs:
Packit 423ecb
 * @elt: HTML element
Packit 423ecb
 *
Packit 423ecb
 * Returns the attributes required for the specified element.
Packit 423ecb
 */
Packit 423ecb
#define htmlRequiredAttrs(elt) (elt)->attrs_req
Packit 423ecb
Packit 423ecb
Packit 423ecb
#ifdef __cplusplus
Packit 423ecb
}
Packit 423ecb
#endif
Packit 423ecb
Packit 423ecb
#endif /* LIBXML_HTML_ENABLED */
Packit 423ecb
#endif /* __HTML_PARSER_H__ */