Documentation ¶
Index ¶
Constants ¶
View Source
const ( TokenPlain = 0 TokenBold = iota TokenItalic = iota TokenCode = iota TokenParagraph = iota TokenImage = iota TokenBullet = iota TokenHeading = iota TokenTable = iota TokenTableRow = iota TokenTableCell = iota TokenUnorderedBullet = iota TokenUnorderedList = iota TokenOrderedBullet = iota TokenOrderedList = iota TokenLink = iota )
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 }, }, TokenUnorderedBullet: Tag{ TrimInside: true, RequiresContent: true, Before: func(s string) string { return "* " + s }, After: func(s string) string { return s + "\n" }, }, TokenOrderedList: Tag{ SkipFirst: true, Before: func(s string) string { return " " + s }, }, TokenOrderedBullet: Tag{ TrimInside: true, RequiresContent: true, ListBefore: func(s string, i int) string { return fmt.Sprintf("%d. ", i) + 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{ Collapse: true, 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{ 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>" }, }, TokenUnorderedBullet: Tag{ Before: func(s string) string { return "<li>" + s }, After: func(s string) string { return s + "</li>" }, }, TokenOrderedList: Tag{ Before: func(s string) string { return "<ol>" + s }, After: func(s string) string { return s + "</ol>" }, }, TokenOrderedBullet: Tag{ ListBefore: func(s string, i int) string { return fmt.Sprintf(`<li value="%d">`, i) + 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{ Collapse: 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 ListItem bool Escape func(string) string Link func(string, string) string Repeat func(int, string) string ListBefore func(string, int) string Before func(string) string After func(string) string MapFile func(downloader.ManifestFile) string }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.