Documentation
¶
Overview ¶
Package a4code2html converts a small markup language into HTML or alternative formats.
Index ¶
- func SanitizeURL(raw string) (string, bool)
- type A4code2html
- func (c *A4code2html) Error() error
- func (c *A4code2html) Escape(ch byte) string
- func (c *A4code2html) Process() io.Reader
- func (c *A4code2html) ProcessReader(r io.Reader, w io.Writer) error
- func (c *A4code2html) SetInput(s string)
- func (c *A4code2html) SetReader(r io.Reader)
- func (c *A4code2html) SetWriter(w io.Writer)
- type CodeType
- type LinkProvider
- type WithTOC
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SanitizeURL ¶
SanitizeURL validates a hyperlink and returns a safe version.
Types ¶
type A4code2html ¶
type A4code2html struct {
CodeType CodeType
// ImageURLMapper optionally maps tag URLs to fully qualified versions.
// The first parameter provides the tag name, e.g. "img" or "a".
ImageURLMapper func(tag, val string) string
// UserColorMapper optionally maps a username to a CSS class for styling quotes.
UserColorMapper func(username string) string
// Provider optionally provides custom rendering for links.
Provider LinkProvider
// contains filtered or unexported fields
}
func New ¶
func New(opts ...interface{}) *A4code2html
New returns a configured A4code2html converter. Optional arguments may set the output CodeType, enable table of contents generation or provide a custom ImageURLMapper. A *bufio.Reader, io.Reader or io.Writer may be supplied to configure the input or output streams.
func (*A4code2html) Error ¶
func (c *A4code2html) Error() error
Error returns the last processing error, if any.
func (*A4code2html) Escape ¶
func (c *A4code2html) Escape(ch byte) string
func (*A4code2html) Process ¶
func (c *A4code2html) Process() io.Reader
Process converts the markup from the configured reader and returns an io.Reader containing the result. If a writer was provided via New or SetWriter, the output is written there and an empty reader is returned.
func (*A4code2html) ProcessReader ¶
ProcessReader converts the markup from r and writes the result to w in a streaming fashion.
func (*A4code2html) SetInput ¶
func (c *A4code2html) SetInput(s string)
SetInput assigns the text to be processed.
func (*A4code2html) SetReader ¶
func (c *A4code2html) SetReader(r io.Reader)
SetReader assigns the reader supplying the markup.
func (*A4code2html) SetWriter ¶
func (c *A4code2html) SetWriter(w io.Writer)
SetWriter assigns the destination for rendered output.