content

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version_v0 = "v0"
)

Variables

View Source
var (
	ContentType_name = map[int32]string{
		0: "CONTENT_TYPE_UNSPECIFIED",
		1: "CONTENT_TYPE_HTML",
		2: "CONTENT_TYPE_PLAIN",
	}
	ContentType_value = map[string]int32{
		"CONTENT_TYPE_UNSPECIFIED": 0,
		"CONTENT_TYPE_HTML":        1,
		"CONTENT_TYPE_PLAIN":       2,
	}
)

Enum value maps for ContentType.

View Source
var (
	NodeType_name = map[int32]string{
		0: "NODE_TYPE_UNSPECIFIED",
		1: "NODE_TYPE_DOC",
		2: "NODE_TYPE_ELEMENT",
		3: "NODE_TYPE_TEXT",
		4: "NODE_TYPE_COMMENT",
	}
	NodeType_value = map[string]int32{
		"NODE_TYPE_UNSPECIFIED": 0,
		"NODE_TYPE_DOC":         1,
		"NODE_TYPE_ELEMENT":     2,
		"NODE_TYPE_TEXT":        3,
		"NODE_TYPE_COMMENT":     4,
	}
)

Enum value maps for NodeType.

View Source
var File_resources_common_content_content_proto protoreflect.FileDescriptor

Functions

func ParseHTML

func ParseHTML(in string) (*html.Node, error)

func PrettyHTML

func PrettyHTML(in string) (string, error)

Types

type Content

type Content struct {
	Version *string   `protobuf:"bytes,1,opt,name=version,proto3,oneof" json:"version,omitempty"`
	Content *JSONNode `protobuf:"bytes,2,opt,name=content,proto3,oneof" json:"content,omitempty"`
	// @sanitize
	RawContent *string `protobuf:"bytes,3,opt,name=raw_content,json=rawContent,proto3,oneof" json:"raw_content,omitempty"`
	// contains filtered or unexported fields
}

func (*Content) Descriptor deprecated

func (*Content) Descriptor() ([]byte, []int)

Deprecated: Use Content.ProtoReflect.Descriptor instead.

func (*Content) GetContent

func (x *Content) GetContent() *JSONNode

func (*Content) GetRawContent

func (x *Content) GetRawContent() string

func (*Content) GetSummary

func (c *Content) GetSummary(length int) string

func (*Content) GetVersion

func (x *Content) GetVersion() string

func (*Content) Populate

func (x *Content) Populate() error

func (*Content) ProtoMessage

func (*Content) ProtoMessage()

func (*Content) ProtoReflect

func (x *Content) ProtoReflect() protoreflect.Message

func (*Content) Reset

func (x *Content) Reset()

func (*Content) Sanitize

func (m *Content) Sanitize() error

func (*Content) Scan

func (x *Content) Scan(value any) error

Scan implements driver.Valuer for protobuf Content.

func (*Content) String

func (x *Content) String() string

func (*Content) Validate

func (m *Content) Validate() error

Validate checks the field values on Content with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*Content) ValidateAll

func (m *Content) ValidateAll() error

ValidateAll checks the field values on Content with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in ContentMultiError, or nil if none found.

func (*Content) Value

func (x *Content) Value() (driver.Value, error)

Value marshals the value into driver.Valuer.

type ContentMultiError

type ContentMultiError []error

ContentMultiError is an error wrapping multiple validation errors returned by Content.ValidateAll() if the designated constraints aren't met.

func (ContentMultiError) AllErrors

func (m ContentMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (ContentMultiError) Error

func (m ContentMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type ContentType

type ContentType int32
const (
	ContentType_CONTENT_TYPE_UNSPECIFIED ContentType = 0
	ContentType_CONTENT_TYPE_HTML        ContentType = 1
	ContentType_CONTENT_TYPE_PLAIN       ContentType = 2
)

func (ContentType) Descriptor

func (ContentType) Enum

func (x ContentType) Enum() *ContentType

func (ContentType) EnumDescriptor deprecated

func (ContentType) EnumDescriptor() ([]byte, []int)

Deprecated: Use ContentType.Descriptor instead.

func (ContentType) Number

func (x ContentType) Number() protoreflect.EnumNumber

func (ContentType) String

func (x ContentType) String() string

func (ContentType) Type

type ContentValidationError

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

ContentValidationError is the validation error returned by Content.Validate if the designated constraints aren't met.

func (ContentValidationError) Cause

func (e ContentValidationError) Cause() error

Cause function returns cause value.

func (ContentValidationError) Error

func (e ContentValidationError) Error() string

Error satisfies the builtin error interface

func (ContentValidationError) ErrorName

func (e ContentValidationError) ErrorName() string

ErrorName returns error name.

func (ContentValidationError) Field

func (e ContentValidationError) Field() string

Field function returns field value.

func (ContentValidationError) Key

func (e ContentValidationError) Key() bool

Key function returns key value.

func (ContentValidationError) Reason

func (e ContentValidationError) Reason() string

Reason function returns reason value.

type JSONNode

type JSONNode struct {
	Type NodeType `protobuf:"varint,1,opt,name=type,proto3,enum=resources.common.content.NodeType" json:"type,omitempty"`
	// @sanitize: method=StripTags
	Id *string `protobuf:"bytes,2,opt,name=id,proto3,oneof" json:"id,omitempty"`
	// @sanitize: method=StripTags
	Tag string `protobuf:"bytes,3,opt,name=tag,proto3" json:"tag,omitempty"`
	// @sanitize: method=StripTags
	Attrs map[string]string `` /* 137-byte string literal not displayed */
	// @sanitize: method=StripTags
	Text    *string     `protobuf:"bytes,5,opt,name=text,proto3,oneof" json:"text,omitempty"`
	Content []*JSONNode `protobuf:"bytes,6,rep,name=content,proto3" json:"content,omitempty"`
	// contains filtered or unexported fields
}

func FromHTMLNode

func FromHTMLNode(node *html.Node) (*JSONNode, error)

FromHTMLNode

func (*JSONNode) Descriptor deprecated

func (*JSONNode) Descriptor() ([]byte, []int)

Deprecated: Use JSONNode.ProtoReflect.Descriptor instead.

func (*JSONNode) GetAttrs

func (x *JSONNode) GetAttrs() map[string]string

func (*JSONNode) GetContent

func (x *JSONNode) GetContent() []*JSONNode

func (*JSONNode) GetId

func (x *JSONNode) GetId() string

func (*JSONNode) GetTag

func (x *JSONNode) GetTag() string

func (*JSONNode) GetText

func (x *JSONNode) GetText() string

func (*JSONNode) GetType

func (x *JSONNode) GetType() NodeType

func (*JSONNode) ProtoMessage

func (*JSONNode) ProtoMessage()

func (*JSONNode) ProtoReflect

func (x *JSONNode) ProtoReflect() protoreflect.Message

func (*JSONNode) Reset

func (x *JSONNode) Reset()

func (*JSONNode) Sanitize

func (m *JSONNode) Sanitize() error

func (*JSONNode) String

func (x *JSONNode) String() string

func (*JSONNode) ToHTML

func (n *JSONNode) ToHTML() (string, error)

ToHTML HTML potentially not pretty

func (*JSONNode) ToHTMLNode

func (n *JSONNode) ToHTMLNode() (*html.Node, error)

ToHTMLNode

func (*JSONNode) ToHTMLP

func (n *JSONNode) ToHTMLP() (string, error)

ToHTMLP Pretty HTML

func (*JSONNode) Validate

func (m *JSONNode) Validate() error

Validate checks the field values on JSONNode with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*JSONNode) ValidateAll

func (m *JSONNode) ValidateAll() error

ValidateAll checks the field values on JSONNode with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in JSONNodeMultiError, or nil if none found.

type JSONNodeMultiError

type JSONNodeMultiError []error

JSONNodeMultiError is an error wrapping multiple validation errors returned by JSONNode.ValidateAll() if the designated constraints aren't met.

func (JSONNodeMultiError) AllErrors

func (m JSONNodeMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (JSONNodeMultiError) Error

func (m JSONNodeMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type JSONNodeValidationError

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

JSONNodeValidationError is the validation error returned by JSONNode.Validate if the designated constraints aren't met.

func (JSONNodeValidationError) Cause

func (e JSONNodeValidationError) Cause() error

Cause function returns cause value.

func (JSONNodeValidationError) Error

func (e JSONNodeValidationError) Error() string

Error satisfies the builtin error interface

func (JSONNodeValidationError) ErrorName

func (e JSONNodeValidationError) ErrorName() string

ErrorName returns error name.

func (JSONNodeValidationError) Field

func (e JSONNodeValidationError) Field() string

Field function returns field value.

func (JSONNodeValidationError) Key

func (e JSONNodeValidationError) Key() bool

Key function returns key value.

func (JSONNodeValidationError) Reason

func (e JSONNodeValidationError) Reason() string

Reason function returns reason value.

type NodeType

type NodeType int32
const (
	NodeType_NODE_TYPE_UNSPECIFIED NodeType = 0
	NodeType_NODE_TYPE_DOC         NodeType = 1
	NodeType_NODE_TYPE_ELEMENT     NodeType = 2
	NodeType_NODE_TYPE_TEXT        NodeType = 3
	NodeType_NODE_TYPE_COMMENT     NodeType = 4
)

func (NodeType) Descriptor added in v0.9.5

func (NodeType) Descriptor() protoreflect.EnumDescriptor

func (NodeType) Enum added in v0.9.5

func (x NodeType) Enum() *NodeType

func (NodeType) EnumDescriptor deprecated added in v0.9.5

func (NodeType) EnumDescriptor() ([]byte, []int)

Deprecated: Use NodeType.Descriptor instead.

func (NodeType) Number added in v0.9.5

func (x NodeType) Number() protoreflect.EnumNumber

func (NodeType) String added in v0.9.5

func (x NodeType) String() string

func (NodeType) Type added in v0.9.5

Jump to

Keyboard shortcuts

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