Documentation
¶
Overview ¶
Package ktw implements fuctionality to write Web applications in a Go centric manner. It implements a simple Markdown converter with extra functionality.
It uses a customized Goldmark Markdown processor that contains a few enhancements. In particular, it allows for special styling of "Note:", "Info:", and "Warning:" paragraphs, which are paragraphs that start with the aforementioned words (with the following ":"). These will be rendered as HTML "<p>" elements with a class of "note", "info", and "warning" respectively.
The code fence has also been enhanced. It uses the Chroma extension to parse and provide spans with classes (as before), but it adds the ability to add attributes to the "<code>" element. In particular, it revives the "class=language-..." class, and adds any other classes and/or IDs that you mention in a custom attribute extension:
```go {.good #example1} package awesome ```
Would result in a code element such as: <code class="language-go good" id="example1">
```go {.bad #example2} package util ```
Would result in a code element such as: <code class="language-go bad" id="example2">
These can be used to provide different styles for different languages, as well as different styles (for example, background color) for code blocks. The IDs can be used to select (or point to) specific code blocks in the rendered HTML.
Index ¶
- func NewCustomCodeHighlight() goldmark.Extender
- func NewInfoBlockParser() parser.BlockParser
- func NewNoteBlockParser() parser.BlockParser
- func NewWarningBlockParser() parser.BlockParser
- type CustomCodeHighlight
- type InfoBlockParser
- type Markdown
- type NoteBlockParser
- type Page
- type Renderer
- type WarningBlockParser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCustomCodeHighlight ¶
NewCustomCodeHighlight returns a wrapped Chroma highlight extension.
func NewInfoBlockParser ¶
func NewInfoBlockParser() parser.BlockParser
NewInfoBlockParser returns a BlockParser that recognizes a "Info:" start, which it then ensures that the class attribute of the resulting HTML element has a "note" class added to aid in styling.
func NewNoteBlockParser ¶
func NewNoteBlockParser() parser.BlockParser
NewNoteBlockParser returns a BlockParser that recognizes a "Note:" start, which it then ensures that the class attribute of the resulting HTML element has a "note" class added to aid in styling.
func NewWarningBlockParser ¶
func NewWarningBlockParser() parser.BlockParser
NewWarningBlockParser returns a BlockParser that recognizes a "Warning:" start, which it then ensures that the class attribute of the resulting HTML element has a "note" class added to aid in styling.
Types ¶
type CustomCodeHighlight ¶
CustomCodeHighlight implements a custom fenced code highlighter that uses Chroma under the hood, but also implements class and general HTML attribute handling.
type InfoBlockParser ¶
type InfoBlockParser struct {
parser.BlockParser
}
InfoBlockParser implements a paragraph block parser that recognizes a paragraph starting with "Info:".
func (*InfoBlockParser) Trigger ¶
func (b *InfoBlockParser) Trigger() []byte
Trigger will be triggered for lines starting with "Info:"
type Markdown ¶
type Markdown []byte
type NoteBlockParser ¶
type NoteBlockParser struct {
parser.BlockParser
}
NoteBlockParser implements a paragraph block parser that recognizes a paragraph starting with "Note:".
func (*NoteBlockParser) Trigger ¶
func (b *NoteBlockParser) Trigger() []byte
Trigger will be triggered for lines starting with "Note:"
type Page ¶
type Page struct { Title string Metadata map[string]string Contents []Renderer // text.Template as we only use it to embed the Markdown rendered HTML // within `<< .Markdown >>`. The resulting document is also a template // and will be rendered using `package "html/template"` as a final pass // with the supplied meatadata. Template *txt.Template }
Page represents a single Web page. It contains everything necessary to let the page's render function produce an HTML representation of the page and all its contents.
type WarningBlockParser ¶
type WarningBlockParser struct {
parser.BlockParser
}
WarningBlockParser implements a paragraph block parser that recognizes a paragraph starting with "Warning:".
func (*WarningBlockParser) Trigger ¶
func (b *WarningBlockParser) Trigger() []byte
Trigger will be triggered for lines starting with "Warning:"