bbcodehtml

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2025 License: ISC Imports: 8 Imported by: 0

README

bbcodehtml

-- import "vimagination.zapto.org/bbcode/bbcodehtml"

This package defines standard bbcode tags.

Usage

Each of the following is a defined BBCode tag that can be parsed to bbcode.New.

Export Tag
Align align: can provide an attribute (left, centre, center, right, full, etc.) to align text.
LeftAlign/CentreAlign/CenterAlign/RightAlign/Full left/centre/center/right/full: used to align text.
Colour/Color colour/color: used to specify a text colour, either as a hex value or a named colour.
Font font: used to specify a custom font.
Bold/Italic/Strikethrough/Underline b/i/s/u: used to format text.
Size size: allows an attribute between 1 and 50 to set the font size.
Header1/Header2/Header3/Header4/Header5/Header6/Header7 h1/h2/h3/h4/h5/h6/h7: headers of various depths.
Quote quote: used to quote text; can provide attr of the quote author.
Code code: used to format code-like text.
Image img: used to add images.
List list: used to creates lists; inner contents should be enclosed in [*][/*] tags.
Table table: used to create tables; allows the use of [thead], [tr], [th], [td], and [tfoot] tags.
URL url: creates a link that points to the attriubte given, wrapping the inner text.

The All export combines all of the above into a single slice ready to be used with bbcode.New.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Align = bbcode.NewAttributeTag("align", divPartialOpen, tagClose, alignAttr, attrClose, divClose, bbcode.AttrFilterFunc(alignFilter))

	LeftAlign   = bbcode.NewTag("left", leftOpen, divClose)
	CentreAlign = bbcode.NewTag("centre", centreOpen, divClose)
	CenterAlign = bbcode.NewTag("center", centreOpen, divClose)
	RightAlign  = bbcode.NewTag("right", rightOpen, divClose)
	FullAlign   = bbcode.NewTag("full", fullOpen, divClose)

	Color  = bbcode.NewAttributeTag("color", spanPartialOpen, tagClose, colourAttr, attrClose, spanClose, Colours)
	Colour = bbcode.NewAttributeTag("colour", spanPartialOpen, tagClose, colourAttr, attrClose, spanClose, Colours)

	Font = bbcode.NewAttributeTag("font", spanPartialOpen, tagClose, fontAttr, attrClose, spanClose, Fonts)

	Bold         = bbcode.NewTag("b", []byte("<b>"), []byte("</b>"))
	Italic       = bbcode.NewTag("i", []byte("<i>"), []byte("</i>"))
	Strikethough = bbcode.NewTag("s", []byte("<s>"), []byte("</s>"))
	Underline    = bbcode.NewTag("u", []byte("<u>"), []byte("</u>"))

	Size = bbcode.NewAttributeTag("size", spanPartialOpen, tagClose, sizeAttr, sizeClose, spanClose, bbcode.AttrFilterFunc(sizeFilter))

	Heading1 = bbcode.NewTag("h1", []byte("<h1>"), []byte("</h1>"))
	Heading2 = bbcode.NewTag("h2", []byte("<h2>"), []byte("</h2>"))
	Heading3 = bbcode.NewTag("h3", []byte("<h3>"), []byte("</h3>"))
	Heading4 = bbcode.NewTag("h4", []byte("<h4>"), []byte("</h4>"))
	Heading5 = bbcode.NewTag("h5", []byte("<h5>"), []byte("</h5>"))
	Heading6 = bbcode.NewTag("h6", []byte("<h6>"), []byte("</h6>"))
	Heading7 = bbcode.NewTag("h7", []byte("<h7>"), []byte("</h7>"))

	Quote = bbcode.NewAttributeTag("quote", []byte("<fieldset class=\"quote\">"), []byte("<blockquote>"), []byte("<legend>"), []byte("</legend>"), []byte("</blockquote></fieldset>"), bbcode.AttrFilterFunc(notEmptyFilter))

	Code  code
	Image img
	List  list
	Table table
	URL   url

	All = []bbcode.Handler{
		Align, LeftAlign, CentreAlign, CenterAlign, RightAlign, FullAlign,
		Colour, Color,
		Font,
		Bold, Italic, Strikethough, Underline,
		Size,
		Heading1, Heading2, Heading3, Heading4, Heading5, Heading6, Heading7,
		Quote,
		Code, Image, List, Table, URL,
	}
)

The following are some predefined bbcode tags for common applications.

View Source
var Colours = colours{}/* 148 elements not displayed */

Colours is a map of colour names to their hex equivalent. It is used as an attribute filter in an bbcode.AttributeTag where it will recognise the contained colours as well as raw hex values.

View Source
var Fonts = fonts{
	"georgia":         georgia,
	"times":           times,
	"times new roman": times,
	"arial":           arial,
	"arial black":     arialBlack,
	"comic sans ms":   comicSans,
	"comic sans":      comicSans,
	"impact":          impact,
	"verdana":         verdana,
	"courier":         courier,
	"lucida console":  lucida,
	"serif":           serif,
	"sans serif":      sansSerif,
	"monospace":       monospace,
}

Fonts is a map of font names and their CSS expansion for use as an attribute filter for bbcode.AttributeTag.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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