Documentation
¶
Overview ¶
Package gotextile provides a stdlib-first Textile parser with fixture-driven compatibility against php-textile.
The renderer supports block and inline Textile constructs (lists, tables, emphasis, links, images, glyph substitutions, footnotes, and more), along with restricted and lite modes. Use DefaultOptions as a baseline and override as needed.
Example:
input := "h1. Hello"
html, err := gotextile.TextileToHtml(input)
if err != nil {
log.Fatal(err)
}
fmt.Println(html)
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TextileToHtml ¶
TextileToHtml converts Textile markup to HTML using DefaultOptions.
Example ¶
input := "h1. Hello" output, _ := TextileToHtml(input) fmt.Print(output)
Output: <h1>Hello</h1>
func TextileToHtmlWithOptions ¶
TextileToHtmlWithOptions converts Textile markup to HTML using the provided options.
The returned HTML includes a trailing newline to match the fixture suite output.
Example ¶
options := DefaultOptions()
options.HTML5 = true
output, _ := TextileToHtmlWithOptions("p. Hi", options)
fmt.Print(output)
Output: <p>Hi</p>
Types ¶
type Options ¶
type Options struct {
// Lite disables most block-level parsing for a lighter-weight subset of Textile.
Lite bool
// Restricted sanitizes HTML and enforces scheme allowlists for links/images.
Restricted bool
// Images enables inline image handling (when false, images are left as text).
Images bool
// DimensionlessImages drops width/height attributes when true.
DimensionlessImages bool
// LinkRelationship sets the rel attribute on generated links (e.g., "nofollow").
LinkRelationship string
// LinkPrefix prepends a prefix to relative link URLs.
LinkPrefix string
// ImagePrefix prepends a prefix to relative image URLs.
ImagePrefix string
// LineWrap controls newline handling; 0 replaces newlines with spaces, -1 preserves them.
LineWrap int
// RawBlocks enables passthrough for raw block tags with custom namespaces.
RawBlocks bool
// BlockTags enables block-level HTML tag parsing/wrapping.
BlockTags bool
// HTML5 switches output to HTML5-style void tags and alignment classes.
HTML5 bool
// NoGlyphs disables glyph substitutions (e.g., smart quotes, ellipses).
NoGlyphs bool
}
Options represents configuration switches for the Textile renderer. These map to the php-textile configuration used in the fixture suite.
func DefaultOptions ¶
func DefaultOptions() Options
DefaultOptions returns the baseline php-textile-compatible defaults.