html_ns

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CLASS_KEY       = "class"
	ID_KEY          = "id"
	CHILDREN_KEY    = "children"
	ANCHOR_HREF_KEY = "href"
	MODEL_KEY       = "model"

	S_NODE_ALREADY_HAS_A_PARENT                    = "node that already has a parent"
	S_NODE_ALREADY_HAS_SIBLINGS                    = "node that already has siblings"
	S_CHILDREN_ALREADY_PROVIDED_WITH_CHILDREN_PROP = "children already provided with .children"
)
View Source
const (
	MAX_PRETTY_PRINT_COST       = 5000
	MAX_PRETTY_PRINT_LINE_COUNT = 200
)
View Source
const MAX_WALKING_DEPTH = 1000
View Source
const (
	NONCE_ATTRIBUTE_NAME = "nonce"
)

Variables

View Source
var (
	//go:embed data.json
	STANDARD_DATA_JSON []byte
	STANDARD_DATA      StandardData

	VOID_HTML_TAG_NAMES []string
)
View Source
var (
	//go:embed jsonform-data.json
	PSEUDO_JSONFORM_DATA_JSON       []byte
	JSONFORM_DATA                   PseudoHtmxData
	JSONFORM_ATTR_NAMES             []string
	SHORTEST_JSONFORM_ATTR_NAME_LEN int = 100
)
View Source
var (
	//go:embed pseudo-htmx-data.json
	PSEUDO_HTMX_DATA_JSON              []byte
	PSEUDO_HTMX_DATA                   PseudoHtmxData
	PSEUDO_HTMX_ATTR_NAMES             []string
	SHORTEST_PSEUDO_HTMX_ATTR_NAME_LEN int = 100
)
View Source
var (
	ErrSingleNode = errors.New("a single HTML node was expected")
)
View Source
var (
	NODE_PATTERN = &core.TypePattern{
		Name:          "html.node",
		Type:          reflect.TypeOf(&HTMLNode{}),
		SymbolicValue: _html_symbolic.NewHTMLNode(),
	}
)

Functions

func EscapeString

func EscapeString(ctx *core.Context, s core.StringLike) core.String

func NewHTMLNamespace

func NewHTMLNamespace() *core.Namespace

func Render

func Render(ctx *core.Context, v core.Value) *core.ByteSlice

func RenderToString

func RenderToString(ctx *core.Context, v core.Value) core.String

Types

type AttributeData

type AttributeData struct {
	Name        string          `json:"name"`
	Description any             `json:"description"` //string | MarkupContent
	ValueSet    string          `json:"valueSet"`
	References  []DataReference `json:"references"`
}

func GetAllTagAttributes

func GetAllTagAttributes(name string) ([]AttributeData, bool)

func GetTagSpecificAttributes

func GetTagSpecificAttributes(name string) ([]AttributeData, bool)

GetTagData returns the specific attributes of a tag (e.g "src" for "img"), the returned data should NOT be modified.

func (AttributeData) DescriptionContent

func (d AttributeData) DescriptionContent() string

func (AttributeData) DescriptionText

func (d AttributeData) DescriptionText() string

type AttributeValueData

type AttributeValueData struct {
	Name        string          `json:"name"`
	Description any             `json:"description"` //string | MarkupContent
	References  []DataReference `json:"references"`
}

func (AttributeValueData) DescriptionContent

func (d AttributeValueData) DescriptionContent() string

func (AttributeValueData) DescriptionText

func (d AttributeValueData) DescriptionText() string

type AttributeValueSet

type AttributeValueSet struct {
	Name   string               `json:"name"`
	Values []AttributeValueData `json:"values"`
}

func GetAttributeValueSet

func GetAttributeValueSet(name string, tagName string) (set AttributeValueSet, found bool)

type DataReference

type DataReference struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

type HTML5DocumentDescription

type HTML5DocumentDescription struct {
	HtmlTagNode *HTMLNode //this value should not be referenced elsewhere
}

type HTMLNode

type HTMLNode struct {
	// contains filtered or unexported fields
}

An HTMLNode is a wrapper around a stdlib's html.Node, HTMLNode implements Value. In Inox code XML expressions with the html namespace evaluate to an HTMLNode.

func CreateHTMLNodeFromXMLElement

func CreateHTMLNodeFromXMLElement(ctx *core.Context, arg *core.XMLElement) *HTMLNode

func CreateSpanElem

func CreateSpanElem(strLike core.StringLike) *HTMLNode

func CreateTextLikeElem

func CreateTextLikeElem(strLike core.StringLike, atom atom.Atom) *HTMLNode

func CreateTextNode

func CreateTextNode(strLike core.StringLike) *HTMLNode

func CreateTimeElem

func CreateTimeElem(strLike core.StringLike) *HTMLNode

func NewHTML5DocumentNodeFromGoDescription

func NewHTML5DocumentNodeFromGoDescription(desc HTML5DocumentDescription) *HTMLNode

func NewHTMLNode

func NewHTMLNode(n *html.Node) *HTMLNode

func NewNode

func NewNode(ctx *core.Context, tag core.String, desc *core.Object) (finalNode *HTMLNode)

func NewNodeFromGoDescription

func NewNodeFromGoDescription(desc NodeDescription) *HTMLNode

func ParseSingleNodeHTML

func ParseSingleNodeHTML(nodeHTML string) (*HTMLNode, error)

func (*HTMLNode) AddNonceToScriptTagsNoEvent

func (n *HTMLNode) AddNonceToScriptTagsNoEvent(nonce string)

func (*HTMLNode) AppendToAttribute

func (n *HTMLNode) AppendToAttribute(ctx *core.Context, newAttr html.Attribute)

func (*HTMLNode) Attr

func (n *HTMLNode) Attr(name string) (string, bool)

func (*HTMLNode) AttrOrEmpty

func (n *HTMLNode) AttrOrEmpty(name string) string

func (*HTMLNode) Clone

func (n *HTMLNode) Clone(originState *core.GlobalState, sharableValues *[]core.PotentiallySharable, clones map[uintptr]core.Clonable, depth int) (core.Value, error)

func (*HTMLNode) Data

func (n *HTMLNode) Data() string

func (*HTMLNode) DiscardCache

func (n *HTMLNode) DiscardCache()

func (*HTMLNode) Equal

func (n *HTMLNode) Equal(ctx *core.Context, other core.Value, alreadyCompared map[uintptr]uintptr, depth int) bool

func (*HTMLNode) GetGoMethod

func (n *HTMLNode) GetGoMethod(name string) (*core.GoFunction, bool)

func (*HTMLNode) HasId

func (n *HTMLNode) HasId() bool

func (*HTMLNode) HasNextSibling

func (n *HTMLNode) HasNextSibling() bool

func (*HTMLNode) HasParent

func (n *HTMLNode) HasParent() bool

func (*HTMLNode) HasPrevSibling

func (n *HTMLNode) HasPrevSibling() bool

func (*HTMLNode) IsElementWithTag

func (n *HTMLNode) IsElementWithTag(tag string) bool

func (*HTMLNode) IsMutable

func (n *HTMLNode) IsMutable() bool

func (*HTMLNode) IsRecursivelyRenderable

func (n *HTMLNode) IsRecursivelyRenderable(ctx *core.Context, input core.RenderingInput) bool

func (*HTMLNode) OnMutation

func (*HTMLNode) PrettyPrint

func (n *HTMLNode) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, parentIndentCount int)

func (*HTMLNode) Prop

func (n *HTMLNode) Prop(ctx *core.Context, name string) core.Value

func (*HTMLNode) PropertyNames

func (n *HTMLNode) PropertyNames(ctx *core.Context) []string

func (*HTMLNode) RemoveAttribute

func (n *HTMLNode) RemoveAttribute(ctx *core.Context, name string)

func (*HTMLNode) RemoveMutationCallback

func (n *HTMLNode) RemoveMutationCallback(ctx *core.Context, handle core.CallbackHandle)

func (*HTMLNode) RemoveMutationCallbackMicrotasks

func (n *HTMLNode) RemoveMutationCallbackMicrotasks(ctx *core.Context)

func (*HTMLNode) Render

func (n *HTMLNode) Render(ctx *core.Context, w io.Writer, config core.RenderingInput) (int, error)

func (*HTMLNode) ReplaceChildHTML

func (n *HTMLNode) ReplaceChildHTML(ctx *core.Context, prevHTMLNode *HTMLNode, child *HTMLNode)

func (*HTMLNode) SetAttribute

func (n *HTMLNode) SetAttribute(ctx *core.Context, newAttr html.Attribute)

func (*HTMLNode) SetId

func (n *HTMLNode) SetId(ctx *core.Context, id core.String)

func (*HTMLNode) SetProp

func (*HTMLNode) SetProp(ctx *core.Context, name string, value core.Value) error

func (*HTMLNode) ToSymbolicValue

func (n *HTMLNode) ToSymbolicValue(ctx *core.Context, encountered map[uintptr]symbolic.Value) (symbolic.Value, error)

func (*HTMLNode) Walk

func (n *HTMLNode) Walk(fn func(n *HTMLNode) error) error

func (*HTMLNode) Watcher

func (n *HTMLNode) Watcher(ctx *core.Context, config core.WatcherConfiguration) core.Watcher

func (*HTMLNode) WriteJSONRepresentation

func (n *HTMLNode) WriteJSONRepresentation(ctx *core.Context, w *jsoniter.Stream, config core.JSONSerializationConfig, depth int) error

func (*HTMLNode) WriteRepresentation

func (n *HTMLNode) WriteRepresentation(ctx *core.Context, w io.Writer, config *core.ReprConfig, depth int) error

type HtmxData

type HtmxData struct {
	Version          float64             `json:"version"`
	GlobalAttributes []AttributeData     `json:"globalAttributes"`
	ValueSets        []AttributeValueSet `json:"valueSets"`
}
var (
	//go:embed htmx-data.json
	HTMX_DATA_JSON []byte
	HTMX_DATA      HtmxData
)

type JSONFormData

type JSONFormData struct {
	Version          float64             `json:"version"`
	GlobalAttributes []AttributeData     `json:"globalAttributes"`
	ValueSets        []AttributeValueSet `json:"valueSets"`
}

type NodeDescription

type NodeDescription struct {
	Tag        string
	Children   []*HTMLNode
	Class      string
	Id         string
	Attributes []html.Attribute
}

type PseudoHtmxData

type PseudoHtmxData struct {
	Version          float64             `json:"version"`
	GlobalAttributes []AttributeData     `json:"globalAttributes"`
	ValueSets        []AttributeValueSet `json:"valueSets"`
}

type StandardData

type StandardData struct {
	Version          float64             `json:"version"`
	Tags             []TagData           `json:"tags"`
	GlobalAttributes []AttributeData     `json:"globalAttributes"`
	ValueSets        []AttributeValueSet `json:"valueSets"`
}

type TagData

type TagData struct {
	Name        string          `json:"name"`
	Description any             `json:"description"` //string | MarkupContent
	Attributes  []AttributeData `json:"attributes"`
	Void        bool            `json:"void"`
	References  []DataReference `json:"references"`
}

func GetTagData

func GetTagData(name string) (TagData, bool)

GetTagData returns the standard data about a tag (e.g "img", "p"), the returned data should NOT be modified.

func (TagData) DescriptionContent

func (d TagData) DescriptionContent() string

func (TagData) DescriptionText

func (d TagData) DescriptionText() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL