Documentation
¶
Index ¶
- Variables
- func FindAllMentions(content string) []string
- func IsMarkdownFile(name string) bool
- func IsReadmeFile(name string) bool
- func Markdown(input interface{}, urlPrefix string) []byte
- func NewSanitizer()
- func RawMarkdown(body []byte, urlPrefix string) []byte
- func Render(typ Type, input interface{}, urlPrefix string) []byte
- func RenderSha1CurrentPattern(rawBytes []byte, urlPrefix string) []byte
- func RenderSpecialLink(rawBytes []byte, urlPrefix string) []byte
- func Sanitize(s string) string
- func SanitizeBytes(b []byte) []byte
- type MarkdownRenderer
- type Sanitizer
- type Type
Constants ¶
This section is empty.
Variables ¶
var ( // MentionPattern matches string that mentions someone, e.g. @Unknwon MentionPattern = regexp.MustCompile(`(\s|^|\W)@[0-9a-zA-Z-_\.]+`) // Sha1CurrentPattern matches string that represents a commit SHA, e.g. d8a994ef243349f321568f9e36d5c3f444b99cae // FIXME: this pattern matches pure numbers as well, right now we do a hack to check in RenderSha1CurrentPattern // by converting string to a number. Sha1CurrentPattern = regexp.MustCompile(`\b[0-9a-f]{40}\b`) )
Functions ¶
func FindAllMentions ¶
FindAllMentions matches mention patterns in given content and returns a list of found user names without @ prefix.
func IsMarkdownFile ¶
IsMarkdownFile reports whether name looks like a Markdown file based on its extension.
func IsReadmeFile ¶
IsReadmeFile reports whether name looks like a README file based on its extension.
func Markdown ¶
Markdown takes a string or []byte and renders to HTML in Markdown syntax with special links.
func NewSanitizer ¶
func NewSanitizer()
NewSanitizer initializes sanitizer with allowed attributes based on settings. Multiple calls to this function will only create one instance of Sanitizer during entire application lifecycle.
func RawMarkdown ¶
RawMarkdown renders Markdown to HTML without handling special links.
func Render ¶
Render takes a string or []byte and renders to HTML in given type of syntax with special links.
func RenderSha1CurrentPattern ¶
RenderSha1CurrentPattern renders SHA1 strings to corresponding links that assumes in the same repository.
func RenderSpecialLink ¶
RenderSpecialLink renders mentions, indexes and SHA1 strings to corresponding links.
func Sanitize ¶
Sanitize takes a string that contains a HTML fragment or document and applies policy whitelist.
func SanitizeBytes ¶
SanitizeBytes takes a []byte slice that contains a HTML fragment or document and applies policy whitelist.
Types ¶
type MarkdownRenderer ¶
type MarkdownRenderer struct { blackfriday.Renderer // contains filtered or unexported fields }
MarkdownRenderer is a extended version of underlying Markdown render object.
func (*MarkdownRenderer) AutoLink ¶
func (r *MarkdownRenderer) AutoLink(out *bytes.Buffer, link []byte, kind int)
AutoLink defines how auto-detected links should be processed to produce corresponding HTML elements. Reference for kind: https://github.com/russross/blackfriday/blob/master/markdown.go#L69-L76