html2bbcode

package module
v0.0.0-...-1a9ce8f Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 6 Imported by: 0

README

html2bbcode

Go library to convert HTML to BBCode. Has one method "Convert" that takes an HTML formatted string, and converts it to BBCode. Returns an error if it can't convert it.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LinkedQuoteRE = regexp.MustCompile(
	`^QuoteJump\(event, '([^']+)'\); return false;$`)

Functions

func AssertElement

func AssertElement(n *html.Node, a atom.Atom) error

func AssertText

func AssertText(n *html.Node, t string) error

func Convert

func Convert(h string) (bb string, err error)

Convert takes an HTML formatted string, and returns a BBCode formattted string or an error if it can't convert it some logic is based on the Gazelle PHP converter

func FirstChild

func FirstChild(n *html.Node) *html.Node

func GetAttr

func GetAttr(n *html.Node, key string) (string, error)

func Next

func Next(n *html.Node) *html.Node

func Parent

func Parent(n *html.Node) *html.Node

func ParseStyle

func ParseStyle(style string) (sk, sv string, err error)

func PartOfAttributedQuote

func PartOfAttributedQuote(n *html.Node) bool

func PartOfHidden

func PartOfHidden(n *html.Node) bool

func PartOfLinkedQuote

func PartOfLinkedQuote(n *html.Node) bool

func Prev

func Prev(n *html.Node) *html.Node

func Text

func Text(n *html.Node) string

Types

type BBCode

type BBCode struct {
	strings.Builder
	// contains filtered or unexported fields
}

func (*BBCode) A

func (bc *BBCode) A(n *html.Node) error

func (*BBCode) Blockquote

func (bc *BBCode) Blockquote(n *html.Node) error

func (*BBCode) Div

func (bc *BBCode) Div(n *html.Node) error

func (*BBCode) DivStyle

func (bc *BBCode) DivStyle(n *html.Node, v string) error

func (*BBCode) Hr

func (bc *BBCode) Hr(n *html.Node) error

func (*BBCode) Img

func (bc *BBCode) Img(n *html.Node) error

func (*BBCode) Node

func (bc *BBCode) Node(n *html.Node, tag string) error

func (*BBCode) NodeData

func (bc *BBCode) NodeData(n *html.Node, tag string) error

func (*BBCode) NodeLiteral

func (bc *BBCode) NodeLiteral(n *html.Node, tag string, l string) error

func (*BBCode) NodeVal

func (bc *BBCode) NodeVal(n *html.Node, tag, v string) error

func (*BBCode) NodeValData

func (bc *BBCode) NodeValData(n *html.Node, tag, v string) error

func (*BBCode) Span

func (bc *BBCode) Span(n *html.Node) error

func (*BBCode) SpanStyle

func (bc *BBCode) SpanStyle(n *html.Node, v string) error

func (*BBCode) Strong

func (bc *BBCode) Strong(n *html.Node) error

func (*BBCode) Url

func (bc *BBCode) Url(n *html.Node, href string) error

Jump to

Keyboard shortcuts

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