Documentation ¶
Index ¶
- Constants
- func BuildOpenTag(tagName string, attributes []attributeInfo, noEvents, noUnknownAttributes bool) string
- func BuildOpenTagHEI(ei *HtmlElementInfo, attributes []attributeInfo, ...) string
- func HtmlAttributeEncode(attributeValue string) string
- type AttrStatus
- type ElementCallback
- type EndElementCallback
- type HtmlElement
- func (he *HtmlElement) AddAttribute(attrName, attrVal string)
- func (he *HtmlElement) FindAttributeIndex(attrName string) int
- func (he *HtmlElement) GetAttributeValue(attrName string) (string, bool)
- func (he *HtmlElement) GetCloseTag() string
- func (he *HtmlElement) GetOpenTag(noEvents, noUnknownAttributes bool) string
- func (he *HtmlElement) HasAttribute(attrName string) bool
- func (he *HtmlElement) RemoveAttribute(attrName string)
- func (he *HtmlElement) SetAttribute(attrName, attrValue string) bool
- type HtmlElementInfo
- type HtmlElementType
- type HtmlParser
- type HtmlTagFormatting
- type QuoteType
- type TextCallback
Constants ¶
View Source
const ( HETPhrasing HtmlElementType = 0x1 // former "inline element" HETFlow = 0x2 // former "block element" HETMeta = 0x4 // control elements HETText = 0x8 // text block HETNRCharData = 0x10 // Non-Replaceable Char Data HETAnyContent = HETPhrasing | HETFlow | HETText HETTransparent = HETPhrasing | HETFlow HETNone = 0 )
Variables ¶
This section is empty.
Functions ¶
func BuildOpenTag ¶
func BuildOpenTagHEI ¶
func BuildOpenTagHEI(ei *HtmlElementInfo, attributes []attributeInfo, noEvents, noUnknownAttributes bool) string
func HtmlAttributeEncode ¶
Types ¶
type AttrStatus ¶
type AttrStatus uint8
AttrStatus indicate a status of an attribute
const ( ASValid AttrStatus = iota ASDeprecated ASUnknown )
type ElementCallback ¶
type ElementCallback func(*HtmlElement, bool)
type EndElementCallback ¶
type EndElementCallback func(string)
type HtmlElement ¶
type HtmlElement struct { TagName string TagNameNS string Id string Attributes []attributeInfo ElementInfo *HtmlElementInfo Namespace string HasNamespace bool XmlEmptyTag bool Parent *HtmlElement HasDeprecatedAttributes bool HasOnlyKnownAttributes bool SyntaxError bool FatalSyntaxError bool OriginalOpenTag string // contains filtered or unexported fields }
func NewHtmlElement ¶
func NewHtmlElement(openElement string, parent *HtmlElement, errors, warnings *[]string) *HtmlElement
func (*HtmlElement) AddAttribute ¶
func (he *HtmlElement) AddAttribute(attrName, attrVal string)
func (*HtmlElement) FindAttributeIndex ¶
func (he *HtmlElement) FindAttributeIndex(attrName string) int
func (*HtmlElement) GetAttributeValue ¶
func (he *HtmlElement) GetAttributeValue(attrName string) (string, bool)
func (*HtmlElement) GetCloseTag ¶
func (he *HtmlElement) GetCloseTag() string
func (*HtmlElement) GetOpenTag ¶
func (he *HtmlElement) GetOpenTag(noEvents, noUnknownAttributes bool) string
func (*HtmlElement) HasAttribute ¶
func (he *HtmlElement) HasAttribute(attrName string) bool
func (*HtmlElement) RemoveAttribute ¶
func (he *HtmlElement) RemoveAttribute(attrName string)
func (*HtmlElement) SetAttribute ¶
func (he *HtmlElement) SetAttribute(attrName, attrValue string) bool
type HtmlElementInfo ¶
type HtmlElementInfo struct { TagName string HtmlVersion int // HTML version that introduced this tag Obsolete bool // Indicates if this element is obsolete TagFormatting HtmlTagFormatting ElementType HtmlElementType PermittedChildrenTypes HtmlElementType // Valid types of elements that can be nested inside this tag PermittedChildrenTags []string // Valid children for this tag Attributes []string ObsoleteAttributes []string ParentContentTypes HtmlElementType ParentTags []string ExcludeParentTags []string // contains filtered or unexported fields }
func GetElementInfo ¶
func GetElementInfo(tagName string) *HtmlElementInfo
GetElementInfo returns the HtmlElementInfo for this tag
func (*HtmlElementInfo) GetAttributeStatus ¶
func (hei *HtmlElementInfo) GetAttributeStatus(attrName string) AttrStatus
func (*HtmlElementInfo) IsValidParent ¶
func (hei *HtmlElementInfo) IsValidParent(parentTagName string) bool
type HtmlElementType ¶
type HtmlElementType uint8
Type of HTML Element according to the HTML 5.0 spec
type HtmlParser ¶
type HtmlParser struct { OrigHtml string Errors []string Warnings []string Ids map[string]bool InnerText string HasValidSyntax bool HasOnlyValidTags bool HasOnlyValidAttributes bool HasOnlyKnownTags bool HasDeprecatedAttributes bool HasDeprecatedTags bool SkipComments bool PreserveCRLFTab bool // contains filtered or unexported fields }
func NewParser ¶
func NewParser(html string) HtmlParser
func (*HtmlParser) IsValidHTML401 ¶
func (parser *HtmlParser) IsValidHTML401() bool
func (*HtmlParser) IsValidStrictHTML401 ¶
func (parser *HtmlParser) IsValidStrictHTML401() bool
func (*HtmlParser) IsValidStrictHTMLNoDeprecated ¶
func (parser *HtmlParser) IsValidStrictHTMLNoDeprecated() bool
func (*HtmlParser) Parse ¶
func (parser *HtmlParser) Parse(textCallback TextCallback, elementCallback ElementCallback, endElementCallback EndElementCallback) bool
func (*HtmlParser) Stop ¶
func (parser *HtmlParser) Stop()
type HtmlTagFormatting ¶
type HtmlTagFormatting uint8
const ( HTFSingle HtmlTagFormatting = iota // Has no closing tag, e.g. <br> HTFOptionalClosing // has an optional closing tag, e.g. <li> HTFComplete // must have a closing tag )
type TextCallback ¶
type TextCallback func(string, *HtmlElement)
Click to show internal directories.
Click to hide internal directories.