markup

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 5 Imported by: 0

README

lucid-markup

lucid-markup is a Go renderer that combines CommonMark/GFM Markdown with the safe BBCode renderer from lucid-bbcode. It converts either format to HTML and preserves the legacy [markdown]...[/markdown] BBCode extension for embedding Markdown inside UBB content.

The module requires Go 1.26.5.

Install

go get github.com/msg7086/lucid-markup@v1.0.0

Usage

package main

import (
	"fmt"

	markup "github.com/msg7086/lucid-markup"
)

func main() {
	markdownHTML, err := markup.Render(
		markup.FormatMarkdown,
		"## Heading\n\n~~done~~",
	)
	if err != nil {
		panic(err)
	}

	bbcodeHTML, err := markup.Render(
		markup.FormatBBCode,
		"[b]bold[/b]",
	)
	if err != nil {
		panic(err)
	}

	nestedHTML, err := markup.Render(
		markup.FormatBBCode,
		"[quote][markdown]**Markdown inside UBB**[/markdown][/quote]",
	)
	if err != nil {
		panic(err)
	}

	fmt.Println(markdownHTML, bbcodeHTML, nestedHTML)
}

Render returns ErrUnsupportedFormat when the input format is unknown. Markdown uses Goldmark's CommonMark and GFM extensions. Raw HTML and unsafe link destinations are not emitted. BBCode rendering is delegated to lucid-bbcode, which applies its own escaping and URL safety rules.

License

MIT. See LICENSE.

Documentation

Overview

Package markup renders supported markup formats as safe HTML.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedFormat = errors.New("unsupported markup format")

ErrUnsupportedFormat is returned when Render receives an unknown format.

Functions

func Render

func Render(format Format, input string) (string, error)

Render converts input in format to HTML. BBCode input may contain a [markdown]...[/markdown] raw tag whose contents are rendered as Markdown.

Types

type Format

type Format string

Format identifies an input markup syntax.

const (
	// FormatMarkdown renders CommonMark with GitHub Flavored Markdown extensions.
	FormatMarkdown Format = "markdown"
	// FormatBBCode renders BBCode using lucid-bbcode.
	FormatBBCode Format = "bbcode"
)

Jump to

Keyboard shortcuts

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