{"modulePath":"github.com/RedAFD/code-core","version":"v1.8.3","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package markup\n\n## Constants\n\n```go\nconst (\n\tIssueNameStyleNumeric      = \"numeric\"\n\tIssueNameStyleAlphanumeric = \"alphanumeric\"\n)\n```\nIssue name styles\n\n## Functions\n\n```go\nfunc FindAllMentions(content string) []string\n```\nFindAllMentions matches mention patterns in given content and returns a list of found user names without @ prefix.\n\n```go\nfunc Init()\n```\nInit initialize regexps for markdown parsing\n\n```go\nfunc IsLink(link []byte) bool\n```\nIsLink reports whether link fits valid format.\n\n```go\nfunc IsMarkupFile(name, markup string) bool\n```\nIsMarkupFile reports whether file is a markup type file\n\n```go\nfunc IsReadmeFile(name string, ext ...string) bool\n```\nIsReadmeFile reports whether name looks like a README file based on its name. If an extension is provided, it will strictly match that extension. Note that the '.' should be provided in ext, e.g \".md\"\n\n```go\nfunc IsSameDomain(s string) bool\n```\nIsSameDomain checks if given url string has the same hostname as current Gitea instance\n\n```go\nfunc NewSanitizer()\n```\nNewSanitizer initializes sanitizer with allowed attributes based on settings. Multiple calls to this function will only create one instance of Sanitizer during entire application lifecycle.\n\n```go\nfunc PostProcess(\n\trawHTML []byte,\n\turlPrefix string,\n\tmetas map[string]string,\n\tisWikiMarkdown bool,\n) ([]byte, error)\n```\nPostProcess does the final required transformations to the passed raw HTML data, and ensures its validity. Transformations include: replacing links and emails with HTML links, parsing shortlinks in the format of \\[\\[Link]], like MediaWiki, linking issues in the format #ID, and mentions in the format @user, and others.\n\n```go\nfunc RegisterParser(parser Parser)\n```\nRegisterParser registers a new markup file parser\n\n```go\nfunc Render(filename string, rawBytes []byte, urlPrefix string, metas map[string]string) []byte\n```\nRender renders markup file to HTML with all specific handling stuff.\n\n```go\nfunc RenderByType(tp string, rawBytes []byte, urlPrefix string, metas map[string]string) []byte\n```\nRenderByType renders markup to HTML with special links and returns string type.\n\n```go\nfunc RenderCommitMessage(\n\trawHTML []byte,\n\turlPrefix, defaultLink string,\n\tmetas map[string]string,\n) ([]byte, error)\n```\nRenderCommitMessage will use the same logic as PostProcess, but will disable the shortLinkProcessor and will add a defaultLinkProcessor if defaultLink is set, which changes every text node into a link to the passed default link.\n\n```go\nfunc RenderDescriptionHTML(\n\trawHTML []byte,\n\turlPrefix string,\n\tmetas map[string]string,\n) ([]byte, error)\n```\nRenderDescriptionHTML will use similar logic as PostProcess, but will use a single special linkProcessor.\n\n```go\nfunc RenderString(filename string, raw, urlPrefix string, metas map[string]string) string\n```\nRenderString renders Markdown to HTML with special links and returns string type.\n\n```go\nfunc RenderWiki(filename string, rawBytes []byte, urlPrefix string, metas map[string]string) string\n```\nRenderWiki renders markdown wiki page to HTML and return HTML string\n\n```go\nfunc Sanitize(s string) string\n```\nSanitize takes a string that contains a HTML fragment or document and applies policy whitelist.\n\n```go\nfunc SanitizeBytes(b []byte) []byte\n```\nSanitizeBytes takes a \\[]byte slice that contains a HTML fragment or document and applies policy whitelist.\n\n```go\nfunc Type(filename string) string\n```\nType returns if markup format via the filename\n\n## Types\n\n```go\ntype Parser interface {\n\tName() string // markup format name\n\tExtensions() []string\n\tRender(rawBytes []byte, urlPrefix string, metas map[string]string, isWiki bool) []byte\n}\n```\nParser defines an interface for parsering markup file to HTML\n\n```go\nfunc GetParserByFileName(filename string) Parser\n```\nGetParserByFileName get parser by filename\n\n```go\nfunc GetParserByType(tp string) Parser\n```\nGetParserByType returns a parser according type\n\n```go\ntype Sanitizer struct {\n\t// contains filtered or unexported fields\n}\n```\nSanitizer is a protection wrapper of \\*bluemonday.Policy which does not allow any modification to the underlying policies once it's been created.\n\n","path":"github.com/RedAFD/code-core/modules/markup","name":"markup","synopsis":"","isRedistributable":true}
