Documentation
¶
Index ¶
- func ConsumeCodeBlock(s ScannerInterface) (string, error)
- func GetNext(s ScannerInterface, endAtEqual bool) (string, error)
- func GetNextArg(s ScannerInterface) (string, error)
- func Parse(r io.Reader) (*ast.Root, error)
- func ParseNodes(s string) ([]ast.Node, error)
- func ParseNodesReader(r io.Reader) ([]ast.Node, error)
- func ParseString(s string) (*ast.Root, error)
- func QuoteText(username, text string, opts ...QuoteOption) string
- func SanitizeURL(raw string) (string, bool)
- func Snip(s string, l int) string
- func SnipText(s string, l int) string
- func SnipTextWords(s string, count int) string
- func SnipWords(s string, count int) string
- func Stream(r io.Reader, opts ...StreamOption) iter.Seq[ast.Node]
- func Substring(s string, start, end int) (string, error)
- func ToA4Code(n ast.Node) string
- func ToCleanText(n ast.Node) string
- func ToCode(n ast.Node) string
- func ToHTML(n ast.Node) string
- func ToText(n ast.Node) string
- type QuoteOption
- type RestrictedQuoteDepth
- type ScannerInterface
- type StreamOption
- type TruncatedQuoteDepth
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConsumeCodeBlock ¶
func ConsumeCodeBlock(s ScannerInterface) (string, error)
ConsumeCodeBlock consumes content bytes until the terminator ']' is found at the top level. It supports escaping characters with backslash. It returns the content string and error.
func GetNext ¶
func GetNext(s ScannerInterface, endAtEqual bool) (string, error)
GetNext reads the next token from the scanner.
func GetNextArg ¶
func GetNextArg(s ScannerInterface) (string, error)
GetNextArg reads the next argument from the scanner, handling optional quotes.
func ParseNodes ¶
ParseNodes parses s and returns only the top-level nodes.
func ParseNodesReader ¶
ParseNodesReader parses r and returns only the top-level nodes.
func ParseString ¶
ParseString parses markup from s and returns the root node.
func QuoteText ¶
func QuoteText(username, text string, opts ...QuoteOption) string
QuoteText wraps the provided text in quote markup for the given user. Behaviour can be customised through QuoteOption values.
func SanitizeURL ¶
SanitizeURL validates a hyperlink and returns a safe version.
func SnipTextWords ¶
func Substring ¶
Substring extracts a substring based on visible text length, preserving markup. start and end are indices into the *visible text*.
func ToCleanText ¶
ToCleanText converts the AST to plain text, stripping all markup and prefixes.
Types ¶
type QuoteOption ¶
type QuoteOption any
QuoteOption configures behaviour of Quote.
func WithFullQuote ¶
func WithFullQuote() QuoteOption
WithFullQuote is a backward-compatible alias for paragraph-aware quoting. Deprecated: use WithParagraphQuote instead.
func WithParagraphQuote ¶
func WithParagraphQuote() QuoteOption
WithParagraphQuote enables paragraph aware quoting.
func WithRestrictedQuoteDepth ¶
func WithRestrictedQuoteDepth(depth int) QuoteOption
WithRestrictedQuoteDepth sets the depth at which quotes are removed.
func WithTrimSpace ¶
func WithTrimSpace() QuoteOption
WithTrimSpace removes surrounding whitespace from the quoted text.
func WithTruncatedQuoteDepth ¶
func WithTruncatedQuoteDepth(depth int) QuoteOption
WithTruncatedQuoteDepth sets the depth at which quote content is removed.
type RestrictedQuoteDepth ¶
type RestrictedQuoteDepth int
RestrictedQuoteDepth is the depth at which quotes are removed.
type ScannerInterface ¶
ScannerInterface abstracts the byte reading methods used by consumeCodeBlock. This allows both bufio.Reader (in a4code2html) and the custom scanner (in parser.go) to be used.
type StreamOption ¶
type StreamOption func(*streamOptions)
StreamOption configures Stream behaviour.
func WithAllNodes ¶
func WithAllNodes() StreamOption
WithAllNodes yields every node encountered while parsing.
func WithDepth ¶
func WithDepth(d int) StreamOption
WithDepth limits yielded nodes to the specified depth, where 0 is top level and -1 yields all nodes.
type TruncatedQuoteDepth ¶
type TruncatedQuoteDepth int
TruncatedQuoteDepth is the depth at which quote content is removed.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package a4code2html converts a small markup language into HTML or alternative formats.
|
Package a4code2html converts a small markup language into HTML or alternative formats. |