Documentation ¶
Overview ¶
Package markdown is middleware to render markdown files as HTML on-the-fly.
Index ¶
- Constants
- func GenerateLinks(md Markdown, cfg *Config) error
- type Config
- type JSONMetadataParser
- type Markdown
- type MarkdownData
- type Metadata
- type MetadataParser
- type PageLink
- type PlaintextRenderer
- func (r PlaintextRenderer) AutoLink(out *bytes.Buffer, link []byte, kind int)
- func (r PlaintextRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string)
- func (r PlaintextRenderer) BlockHtml(out *bytes.Buffer, text []byte)
- func (r PlaintextRenderer) BlockQuote(out *bytes.Buffer, text []byte)
- func (r PlaintextRenderer) CodeSpan(out *bytes.Buffer, text []byte)
- func (r PlaintextRenderer) DocumentFooter(out *bytes.Buffer)
- func (r PlaintextRenderer) DocumentHeader(out *bytes.Buffer)
- func (r PlaintextRenderer) DoubleEmphasis(out *bytes.Buffer, text []byte)
- func (r PlaintextRenderer) Emphasis(out *bytes.Buffer, text []byte)
- func (r PlaintextRenderer) Entity(out *bytes.Buffer, entity []byte)
- func (r PlaintextRenderer) FootnoteItem(out *bytes.Buffer, name, text []byte, flags int)
- func (r PlaintextRenderer) FootnoteRef(out *bytes.Buffer, ref []byte, id int)
- func (r PlaintextRenderer) Footnotes(out *bytes.Buffer, text func() bool)
- func (r PlaintextRenderer) GetFlags() int
- func (r PlaintextRenderer) HRule(out *bytes.Buffer)
- func (r PlaintextRenderer) Header(out *bytes.Buffer, text func() bool, level int, id string)
- func (r PlaintextRenderer) Image(out *bytes.Buffer, link []byte, title []byte, alt []byte)
- func (r PlaintextRenderer) LineBreak(out *bytes.Buffer)
- func (r PlaintextRenderer) Link(out *bytes.Buffer, link []byte, title []byte, content []byte)
- func (r PlaintextRenderer) List(out *bytes.Buffer, text func() bool, flags int)
- func (r PlaintextRenderer) ListItem(out *bytes.Buffer, text []byte, flags int)
- func (r PlaintextRenderer) NormalText(out *bytes.Buffer, text []byte)
- func (r PlaintextRenderer) Paragraph(out *bytes.Buffer, text func() bool)
- func (r PlaintextRenderer) RawHtmlTag(out *bytes.Buffer, tag []byte)
- func (r PlaintextRenderer) StrikeThrough(out *bytes.Buffer, text []byte)
- func (r PlaintextRenderer) Table(out *bytes.Buffer, header []byte, body []byte, columnData []int)
- func (r PlaintextRenderer) TableCell(out *bytes.Buffer, text []byte, flags int)
- func (r PlaintextRenderer) TableHeaderCell(out *bytes.Buffer, text []byte, flags int)
- func (r PlaintextRenderer) TableRow(out *bytes.Buffer, text []byte)
- func (r PlaintextRenderer) TitleBlock(out *bytes.Buffer, text []byte)
- func (r PlaintextRenderer) TripleEmphasis(out *bytes.Buffer, text []byte)
- type TOMLMetadataParser
- type YAMLMetadataParser
Constants ¶
const ( DefaultTemplate = "defaultTemplate" DefaultStaticDir = "generated_site" )
Variables ¶
This section is empty.
Functions ¶
func GenerateLinks ¶ added in v0.7.4
GenerateLinks generates links to all markdown files ordered by newest date. This blocks until link generation is done. When called by multiple goroutines, the first caller starts the generation and others only wait.
Types ¶
type Config ¶ added in v0.6.0
type Config struct { // Markdown renderer Renderer blackfriday.Renderer // Base path to match PathScope string // List of extensions to consider as markdown files Extensions []string // List of style sheets to load for each markdown file Styles []string // List of JavaScript files to load for each markdown file Scripts []string // Map of registered templates Templates map[string]string // Map of request URL to static files generated StaticFiles map[string]string // Links to all markdown pages ordered by date. Links []PageLink // Directory to store static files StaticDir string sync.RWMutex }
Config stores markdown middleware configurations.
type JSONMetadataParser ¶ added in v0.7.0
type JSONMetadataParser struct {
// contains filtered or unexported fields
}
JSONMetadataParser is the MetadataParser for JSON
func (*JSONMetadataParser) Closing ¶ added in v0.7.0
func (j *JSONMetadataParser) Closing() []byte
Closing returns the closing identifier JSON metadata
func (*JSONMetadataParser) Metadata ¶ added in v0.7.0
func (j *JSONMetadataParser) Metadata() Metadata
Metadata returns parsed metadata. It should be called only after a call to Parse returns without error.
func (*JSONMetadataParser) Opening ¶ added in v0.7.0
func (j *JSONMetadataParser) Opening() []byte
Opening returns the opening identifier JSON metadata
type Markdown ¶
type Markdown struct { // Server root Root string // Jail the requests to site root with a mock file system FileSys http.FileSystem // Next HTTP handler in the chain Next middleware.Handler // The list of markdown configurations Configs []Config // The list of index files to try IndexFiles []string }
Markdown implements a layer of middleware that serves markdown as HTML.
func (Markdown) IsIndexFile ¶ added in v0.7.0
IsIndexFile checks to see if a file is an index file
type MarkdownData ¶ added in v0.7.4
type MarkdownData struct { middleware.Context Doc map[string]string Links []PageLink }
type Metadata ¶ added in v0.7.0
type Metadata struct { // Page title Title string // Page template Template string // Publish date Date time.Time // Variables to be used with Template Variables map[string]string }
Metadata stores a page's metadata
type MetadataParser ¶ added in v0.7.0
type MetadataParser interface { // Opening identifier Opening() []byte // Closing identifier Closing() []byte // Parse the metadata. // Returns the remaining page contents (Markdown) // after extracting metadata Parse([]byte) ([]byte, error) // Parsed metadata. // Should be called after a call to Parse returns no error Metadata() Metadata }
MetadataParser is a an interface that must be satisfied by each parser
type PlaintextRenderer ¶ added in v0.7.4
type PlaintextRenderer struct{}
func (PlaintextRenderer) AutoLink ¶ added in v0.7.4
func (r PlaintextRenderer) AutoLink(out *bytes.Buffer, link []byte, kind int)
func (PlaintextRenderer) BlockCode ¶ added in v0.7.4
func (r PlaintextRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string)
func (PlaintextRenderer) BlockHtml ¶ added in v0.7.4
func (r PlaintextRenderer) BlockHtml(out *bytes.Buffer, text []byte)
func (PlaintextRenderer) BlockQuote ¶ added in v0.7.4
func (r PlaintextRenderer) BlockQuote(out *bytes.Buffer, text []byte)
func (PlaintextRenderer) CodeSpan ¶ added in v0.7.4
func (r PlaintextRenderer) CodeSpan(out *bytes.Buffer, text []byte)
func (PlaintextRenderer) DocumentFooter ¶ added in v0.7.4
func (r PlaintextRenderer) DocumentFooter(out *bytes.Buffer)
func (PlaintextRenderer) DocumentHeader ¶ added in v0.7.4
func (r PlaintextRenderer) DocumentHeader(out *bytes.Buffer)
func (PlaintextRenderer) DoubleEmphasis ¶ added in v0.7.4
func (r PlaintextRenderer) DoubleEmphasis(out *bytes.Buffer, text []byte)
func (PlaintextRenderer) Emphasis ¶ added in v0.7.4
func (r PlaintextRenderer) Emphasis(out *bytes.Buffer, text []byte)
func (PlaintextRenderer) Entity ¶ added in v0.7.4
func (r PlaintextRenderer) Entity(out *bytes.Buffer, entity []byte)
func (PlaintextRenderer) FootnoteItem ¶ added in v0.7.4
func (r PlaintextRenderer) FootnoteItem(out *bytes.Buffer, name, text []byte, flags int)
func (PlaintextRenderer) FootnoteRef ¶ added in v0.7.4
func (r PlaintextRenderer) FootnoteRef(out *bytes.Buffer, ref []byte, id int)
func (PlaintextRenderer) Footnotes ¶ added in v0.7.4
func (r PlaintextRenderer) Footnotes(out *bytes.Buffer, text func() bool)
func (PlaintextRenderer) GetFlags ¶ added in v0.7.4
func (r PlaintextRenderer) GetFlags() int
func (PlaintextRenderer) HRule ¶ added in v0.7.4
func (r PlaintextRenderer) HRule(out *bytes.Buffer)
func (PlaintextRenderer) LineBreak ¶ added in v0.7.4
func (r PlaintextRenderer) LineBreak(out *bytes.Buffer)
func (PlaintextRenderer) List ¶ added in v0.7.4
func (r PlaintextRenderer) List(out *bytes.Buffer, text func() bool, flags int)
func (PlaintextRenderer) ListItem ¶ added in v0.7.4
func (r PlaintextRenderer) ListItem(out *bytes.Buffer, text []byte, flags int)
func (PlaintextRenderer) NormalText ¶ added in v0.7.4
func (r PlaintextRenderer) NormalText(out *bytes.Buffer, text []byte)
func (PlaintextRenderer) Paragraph ¶ added in v0.7.4
func (r PlaintextRenderer) Paragraph(out *bytes.Buffer, text func() bool)
func (PlaintextRenderer) RawHtmlTag ¶ added in v0.7.4
func (r PlaintextRenderer) RawHtmlTag(out *bytes.Buffer, tag []byte)
func (PlaintextRenderer) StrikeThrough ¶ added in v0.7.4
func (r PlaintextRenderer) StrikeThrough(out *bytes.Buffer, text []byte)
func (PlaintextRenderer) TableCell ¶ added in v0.7.4
func (r PlaintextRenderer) TableCell(out *bytes.Buffer, text []byte, flags int)
func (PlaintextRenderer) TableHeaderCell ¶ added in v0.7.4
func (r PlaintextRenderer) TableHeaderCell(out *bytes.Buffer, text []byte, flags int)
func (PlaintextRenderer) TableRow ¶ added in v0.7.4
func (r PlaintextRenderer) TableRow(out *bytes.Buffer, text []byte)
func (PlaintextRenderer) TitleBlock ¶ added in v0.7.4
func (r PlaintextRenderer) TitleBlock(out *bytes.Buffer, text []byte)
func (PlaintextRenderer) TripleEmphasis ¶ added in v0.7.4
func (r PlaintextRenderer) TripleEmphasis(out *bytes.Buffer, text []byte)
type TOMLMetadataParser ¶ added in v0.7.0
type TOMLMetadataParser struct {
// contains filtered or unexported fields
}
TOMLMetadataParser is the MetadataParser for TOML
func (*TOMLMetadataParser) Closing ¶ added in v0.7.0
func (t *TOMLMetadataParser) Closing() []byte
Closing returns the closing identifier TOML metadata
func (*TOMLMetadataParser) Metadata ¶ added in v0.7.0
func (t *TOMLMetadataParser) Metadata() Metadata
Metadata returns parsed metadata. It should be called only after a call to Parse returns without error.
func (*TOMLMetadataParser) Opening ¶ added in v0.7.0
func (t *TOMLMetadataParser) Opening() []byte
Opening returns the opening identifier TOML metadata
type YAMLMetadataParser ¶ added in v0.7.0
type YAMLMetadataParser struct {
// contains filtered or unexported fields
}
YAMLMetadataParser is the MetadataParser for YAML
func (*YAMLMetadataParser) Closing ¶ added in v0.7.0
func (y *YAMLMetadataParser) Closing() []byte
Closing returns the closing identifier YAML metadata
func (*YAMLMetadataParser) Metadata ¶ added in v0.7.0
func (y *YAMLMetadataParser) Metadata() Metadata
Metadata returns parsed metadata. It should be called only after a call to Parse returns without error.
func (*YAMLMetadataParser) Opening ¶ added in v0.7.0
func (y *YAMLMetadataParser) Opening() []byte
Opening returns the opening identifier YAML metadata