bbcode

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package bbcode provides shared BBCode cleanup and normalization primitives.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertCodeToPre

func ConvertCodeToPre(value string) string

ConvertCodeToPre changes code tags to pre tags.

func ConvertCodeToQuote

func ConvertCodeToQuote(value string) string

ConvertCodeToQuote changes code tags to quote tags.

func ConvertCollapseToComparison

func ConvertCollapseToComparison(value string, spoilerHide string, collapses []string) string

ConvertCollapseToComparison converts screenshot comparison collapses to BBCode comparisons.

func ConvertComparisonToCentered

func ConvertComparisonToCentered(value string, maxWidth int) string

ConvertComparisonToCentered renders comparison blocks as centered screenshots.

func ConvertComparisonToCollapse

func ConvertComparisonToCollapse(value string, maxWidth int) string

ConvertComparisonToCollapse converts comparison blocks to spoilers.

func ConvertHideToSpoiler

func ConvertHideToSpoiler(value string) string

ConvertHideToSpoiler changes hide tags to spoiler tags.

func ConvertNamedSpoilerToNamedHide

func ConvertNamedSpoilerToNamedHide(value string) string

ConvertNamedSpoilerToNamedHide converts named spoilers to named hides.

func ConvertNamedSpoilerToNormalSpoiler

func ConvertNamedSpoilerToNormalSpoiler(value string) string

ConvertNamedSpoilerToNormalSpoiler removes spoiler titles.

func ConvertPreToCode

func ConvertPreToCode(value string) string

ConvertPreToCode changes pre tags to code tags.

func ConvertSpoilerToHide

func ConvertSpoilerToHide(value string) string

ConvertSpoilerToHide changes spoiler tags to hide tags.

func ConvertToAlign

func ConvertToAlign(value string) string

ConvertToAlign converts positional tags to align tags.

func IsOnlyTags

func IsOnlyTags(value string) bool

IsOnlyTags reports whether value contains no text outside BBCode tags.

func NormalizeImageRawURL

func NormalizeImageRawURL(value string) string

NormalizeImageRawURL expands supported thumbnail and viewer URLs to their full-size images, including image URLs wrapped by known wsrv proxies.

func NormalizeNewlines

func NormalizeNewlines(value string) string

NormalizeNewlines decodes HTML entities and normalizes CRLF line endings.

func RemoveColor

func RemoveColor(value string) string

RemoveColor removes color tags.

func RemoveExtraLines

func RemoveExtraLines(value string) string

RemoveExtraLines collapses three or more consecutive newlines.

func RemoveHide

func RemoveHide(value string) string

RemoveHide removes hide tags.

func RemoveImageResize

func RemoveImageResize(value string) string

RemoveImageResize removes image tag attributes.

func RemoveList

func RemoveList(value string) string

RemoveList removes list container tags.

func RemoveSpoiler

func RemoveSpoiler(value string) string

RemoveSpoiler removes spoiler tags.

func RemoveSub

func RemoveSub(value string) string

RemoveSub removes sub tags.

func RemoveSup

func RemoveSup(value string) string

RemoveSup removes sup tags.

Types

type Artifact

type Artifact struct {
	// Name is the suggested artifact filename.
	Name string
	// Kind categorizes the extracted artifact.
	Kind string
	// Content is the extracted artifact body.
	Content string
}

Artifact contains auxiliary content extracted from a description.

type Image

type Image struct {
	// ImgURL is the BBCode-ready image URL, which may point at a thumbnail.
	ImgURL string
	// RawURL is the direct image URL.
	RawURL string
	// WebURL is the image host's browser-facing page URL when available.
	WebURL string
	// Host is the normalized image-host name, such as "imgbb" or "pixhost".
	Host string
}

Image describes an image extracted while cleaning a BBCode description.

type Note

type Note struct {
	// Kind categorizes the note for downstream handling.
	Kind string
	// Message contains caller-visible detail about the condition.
	Message string
}

Note reports a non-fatal condition encountered while cleaning a description.

type Report

type Report struct {
	// Description is the normalized BBCode that remains after cleanup.
	Description string
	// Images contains images removed or identified during cleanup.
	Images []Image
	// Notes contains non-fatal cleanup diagnostics.
	Notes []Note
	// Artifacts contains auxiliary files extracted from the description.
	Artifacts []Artifact
}

Report contains a cleaned description and content extracted during cleanup.

func CleanPTPDescription

func CleanPTPDescription(description string, discType string) Report

CleanPTPDescription removes tracker links, embedded MediaInfo, unsupported blocks, and known uploader signatures from a PTP-style description. It returns extracted images separately, preserves comparison blocks byte for byte, and omits a cleaned body that is blank or contains only BBCode tags.

func CleanUnit3DDescription

func CleanUnit3DDescription(description string, site string) Report

CleanUnit3DDescription removes site-local links and image markup from a Unit3D description, returning the first non-poster image set separately from the cleaned body.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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