bbConvert

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2024 License: MIT Imports: 3 Imported by: 1

README

bbConvert GoDoc Coverage Status Build Status Go Report Card

bbConvert is an easy way to process and convert bbCode to whatever you'd like. HTMLConverter is a converter from bbCode to HTML with some defaults (probably more than you'll need) ready if you use ImplementDefaults().

Support

If you have any questions, feel free to open an issue and ask it. I don't have a life, I'll probably answer quickly.

HTML Defaults

[b]Some Text[/b] //bolded text
[bold]Some Text[/bold] //bolded text
[i]Some Text[/i] //italicized text
[italics]Some Text[/italics] //italicized text
[u]Some Text[/u] //underlined text
[underline]Some Text[/underline] //underlined text
[s]some Text[/s] //strikedthrough text
[strike]Some Text[/strike] //strikethrough text
[font=Verdana]Some Text[/font] //text in verdana font
[font size=20pt]Some Text[/font] //20pt size text
[font color=red]Some Text[/font] //red text
[font color=#000000]Some Text[/font] //text with the color of #000000. The # is unnecessary
[font variant=upper]Some Text[/font] //uppercased text
[font variant=lower]Some Text[/font] //lowercase text
[font variant=smallcaps]Some Text[/font] //smallcaps text
[size=20pt]Some Text[/size] //20pt size text
[color=red]Some Text[/color] //red text
[color=#000000]Some Text[/color] //text with the color of #000000. The # is unnecessary
[smallcaps]Some Text[/smallcaps] //smallcaps text
[url]Link address[/url] //linked text
[url=address]Some Text[/url] //linked text
[url title="Title"]Link address[/url] //linked text with title
[link]Link address[/link] //linked text
[link=address]Some Text[/link] //linked text
[link title="Title"]Link address[/link] //linked text with title
[youtube]Youtube URL or video ID[/youtube] //youtube video
[youtube height=200 width=500]Youtube URL or video ID[/youtube] //youtube video with set size
[youtube=500x200]Youtube URL or video ID[/youtube] //youtube video with set size
[youtube left]Youtube URL or video ID[/youtube] //youtube video floated left
[youtube right]Youtube URL or video ID[/youtube] //youtube video floated right
[img]Image URL[/img] //an image
[img=500x200]Image URL[/img] //an image with set size
[img height=200 width=500]Image URL[/img] //an image with set size
[img left]Image URL[/img] //an image floated left
[img right]Image URL[/img] //an image floated right
[img alt="Alternate text"]Image URL[/img] //an image with alternate text
[img title="Title"]Image URL[/img] //an image with title
[image]Image URL[/image] //same as [img] tag
[title]Some Text[/title] //Large text made for use as a title
[t1]Some Text[/t1] //Large text made for use as a title. Same as [title]
[t2]Some Text[/t2] //Slightly smaller text than [t1]. Meant for use as a title of some sort
[t3]Some Text[/t3] //Slightly smaller text than [t2]. Meant for use as a title of some sort
[t4]Some Text[/t4] //Slightly smaller text than [t3]. Meant for use as a title of some sort
[t5]Some Text[/t5] //Slightly smaller text than [t4]. Meant for use as a title of some sort
[t6]Some Text[/t6] //Slightly smaller text than [t5]. Meant for use as a title of some sort
[align=center]Some Text[/align] //Aligns the insides (encapsulates the insides in a div)
[bullet]Bullet 1 * Bullet 2[/bullet] //bulleted list
[ul]
* Item 1
Item 2
[/ul] //an unordered (bulleted) list
[ol]
* Item 1
Item 2
[/ol] //an ordered (numbered) list
[bullet] * Item 1 * Item 2[/bullet] //same as [ul]
[number] * Item 1 * Item 2[/number] //same as [ol]
[ul]* Item 1 * Item 2[/ul] //an unordered (bulleted) list
[ol]* Item 1 * Item 2[/ol] //an ordered (numbered) list

Documentation

Overview

Package bbConvert provides an easy way to process and convert bbCode. HTMLConverter is an easier way to convert to HTML.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Converter

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

Converter provides an easy way to convert bbCode.

func (*Converter) AddCustom

func (c *Converter) AddCustom(bbType string, f func(Tag, string) string)

AddCustom adds a conversion function to the Converter. bbType is self explanitory (it is case insensitive) and the function is type func(Tag,string) string: The first input is the front Tag and the second input in the text found in between the two matched tags

func (Converter) Convert

func (c Converter) Convert(in string) string

Convert converts the input string.

type HTMLConverter

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

HTMLConverter is an easy way to convert bbCode to HTML. It automatically wraps the output in paragraph tags and properly converts newlines (\n) to paragraphs.

func (*HTMLConverter) AddClass

func (h *HTMLConverter) AddClass(class string)

AddClass adds a class to the paragraph tags used to wrap the output. Multiple classes can be added at once if they are separated by spaces.

func (*HTMLConverter) Convert

func (h *HTMLConverter) Convert(in string) string

Convert converts the input with bbCode to output with HTML

func (*HTMLConverter) Converter

func (h *HTMLConverter) Converter() *Converter

Converter returns the Converter that's used in the HTMLConverter so you can add custom functions and other items that you can access with the Converter

func (*HTMLConverter) ImplementDefaults

func (h *HTMLConverter) ImplementDefaults()

ImplementDefaults adds the default supported bbCode to HTML conversions.

func (*HTMLConverter) SetStyle

func (h *HTMLConverter) SetStyle(css, value string)

SetStyle sets a give style to the paragraph tags used to wrap the output.

func (*HTMLConverter) StartingParagraphTag

func (h *HTMLConverter) StartingParagraphTag() string

StartingParagraphTag returns the starting paragraph tags used when wraping the output in paragraph tags with the proper style and class(es)

type Tag

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

Tag is a bbCode tag that is properly processed.

func (*Tag) Value

func (t *Tag) Value(param string) string

Value returns the value of a parameter of the bbCode tag. Starting parameters is under "starting". Parameter names are always in lowercase

Jump to

Keyboard shortcuts

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