Documentation
¶
Index ¶
Constants ¶
Variables ¶
View Source
var ConvertMap = map[string]TagSet{ "md": { TokenPlain: Tag{ Collapse: true, LeftPad: true, Escape: func(s string) string { return markdownEscape(s) }, }, TokenBold: Tag{ Collapse: true, LeftPad: true, TrimInside: true, RequiresContent: true, Before: func(s string) string { return "**" + s }, After: func(s string) string { return s + "**" }, }, TokenItalic: Tag{ TrimInside: true, LeftPad: true, Collapse: true, RequiresContent: true, Before: func(s string) string { return "_" + s }, After: func(s string) string { return s + "_" }, }, TokenParagraph: Tag{ TrimInside: true, Before: func(s string) string { return "\n" + s }, After: func(s string) string { return s + "\n" }, }, TokenUnorderedList: Tag{ SkipFirst: true, Before: func(s string) string { return " " + s }, }, TokenBullet: Tag{ TrimInside: true, RequiresContent: true, Before: func(s string) string { return "* " + s }, After: func(s string) string { return s + "\n" }, }, TokenHeading: Tag{ TrimInside: true, RequiresContent: true, Repeat: func(times int, s string) string { return strings.Repeat("#", times) + " " + s }, After: func(s string) string { return s + "\n" }, }, TokenTable: Tag{ Before: func(s string) string { return "<table>" + s }, After: func(s string) string { return s + "</table>" }, }, TokenTableCell: Tag{ TrimInside: true, Before: func(s string) string { return "<td>" + s }, After: func(s string) string { return s + "</td>" }, }, TokenTableRow: Tag{ Before: func(s string) string { return "<tr>" + s }, After: func(s string) string { return s + "</tr>" }, }, TokenImage: Tag{ MapFile: func(file downloader.ManifestFile) string { return fmt.Sprintf("<img src=%q height=%d width=%d />", file.Filename, file.Height, file.Width) }, }, TokenCode: Tag{ NoEscape: true, RequiresContent: true, Before: func(s string) string { if strings.Contains(s, "\n") { return "```\n" + s } return "`" + s }, After: func(s string) string { if strings.Contains(s, "\n") { return s + "\n```\n" } return s + "`" }, }, TokenLink: Tag{ LeftPad: true, Link: func(href, s string) string { return fmt.Sprintf("[%s](%s)", markdownEscape(s), href) }, }, }, "html": { TokenPlain: Tag{ Collapse: true, Escape: func(s string) string { if len(s) > 0 { s = html.EscapeString(s) if s[0] == ' ' { s = " " + s[1:] } if s[len(s)-1] == ' ' { s = s[:len(s)-1] + " " } } return s }, }, TokenBold: Tag{ Collapse: true, TrimInside: true, Before: func(s string) string { return "<b>" + s }, After: func(s string) string { return s + "</b>" }, }, TokenItalic: Tag{ Collapse: true, RequiresContent: true, TrimInside: true, Before: func(s string) string { return "<i>" + s }, After: func(s string) string { return s + "</i>" }, }, TokenParagraph: Tag{ Collapse: true, LeftPad: true, TrimInside: true, RequiresContent: true, Before: func(s string) string { return "<p>" + s }, After: func(s string) string { return s + "</p>\n" }, }, TokenUnorderedList: Tag{ Before: func(s string) string { return "<ul>" + s }, After: func(s string) string { return s + "</ul>" }, }, TokenBullet: Tag{ Before: func(s string) string { return "<li>" + s }, After: func(s string) string { return s + "</li>" }, }, TokenHeading: Tag{ TrimInside: true, RequiresContent: true, Repeat: func(times int, s string) string { return fmt.Sprintf("<h%d>%s</h%d>", times, s, times) }, }, TokenTable: Tag{ Before: func(s string) string { return "<table>" + s }, After: func(s string) string { return s + "</table>" }, }, TokenTableCell: Tag{ TrimInside: true, Before: func(s string) string { return "<td>" + s }, After: func(s string) string { return s + "</td>" }, }, TokenTableRow: Tag{ Before: func(s string) string { return "<tr>" + s }, After: func(s string) string { return s + "</tr>" }, }, TokenImage: Tag{ MapFile: func(file downloader.ManifestFile) string { return fmt.Sprintf("<img src=%q height=%d width=%d />", file.Filename, file.Height, file.Width) }, }, TokenCode: Tag{ TrimInside: true, RequiresContent: true, LeftPad: true, Before: func(s string) string { if strings.Contains(s, "\n") { return "\n<pre><code>" + s } return "<code>" + s }, After: func(s string) string { if strings.Contains(s, "\n") { return s + "</code></pre>\n" } return s + "</code>" }, }, TokenLink: Tag{ Link: func(href, s string) string { return fmt.Sprintf("<a href=%q>%s</a>", href, s) }, }, }, }
Functions ¶
Types ¶
type Node ¶
type Tag ¶
type Tag struct {
NoEscape bool
SkipFirst bool
Collapse bool
RequiresContent bool
LeftPad bool
TrimInside bool
Escape func(string) string
Link func(string, string) string
Repeat func(int, string) string
Before func(string) string
After func(string) string
MapFile func(downloader.ManifestFile) string
}
Click to show internal directories.
Click to hide internal directories.