gitea: code.gitea.io/gitea/modules/markup Index | Files | Directories

package markup

import "code.gitea.io/gitea/modules/markup"

Index

Package Files

html.go markup.go sanitizer.go

Constants

const (
    IssueNameStyleNumeric      = "numeric"
    IssueNameStyleAlphanumeric = "alphanumeric"
)

Issue name styles

func CustomLinkURLSchemes Uses

func CustomLinkURLSchemes(schemes []string)

CustomLinkURLSchemes allows for additional schemes to be detected when parsing links within text

func Init Uses

func Init()

Init initialize regexps for markdown parsing

func IsLink(link []byte) bool

IsLink reports whether link fits valid format.

func IsMarkupFile Uses

func IsMarkupFile(name, markup string) bool

IsMarkupFile reports whether file is a markup type file

func IsReadmeFile Uses

func IsReadmeFile(name string, ext ...string) bool

IsReadmeFile 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"

func IsSameDomain Uses

func IsSameDomain(s string) bool

IsSameDomain checks if given url string has the same hostname as current Gitea instance

func NewSanitizer Uses

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 PostProcess Uses

func PostProcess(
    rawHTML []byte,
    urlPrefix string,
    metas map[string]string,
    isWikiMarkdown bool,
) ([]byte, error)

PostProcess 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.

func RegisterParser Uses

func RegisterParser(parser Parser)

RegisterParser registers a new markup file parser

func Render Uses

func Render(filename string, rawBytes []byte, urlPrefix string, metas map[string]string) []byte

Render renders markup file to HTML with all specific handling stuff.

func RenderByType Uses

func RenderByType(tp string, rawBytes []byte, urlPrefix string, metas map[string]string) []byte

RenderByType renders markup to HTML with special links and returns string type.

func RenderCommitMessage Uses

func RenderCommitMessage(
    rawHTML []byte,
    urlPrefix, defaultLink string,
    metas map[string]string,
) ([]byte, error)

RenderCommitMessage 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.

func RenderCommitMessageSubject Uses

func RenderCommitMessageSubject(
    rawHTML []byte,
    urlPrefix, defaultLink string,
    metas map[string]string,
) ([]byte, error)

RenderCommitMessageSubject will use the same logic as PostProcess and RenderCommitMessage, but will disable the shortLinkProcessor and emailAddressProcessor, will add a defaultLinkProcessor if defaultLink is set, which changes every text node into a link to the passed default link.

func RenderDescriptionHTML Uses

func RenderDescriptionHTML(
    rawHTML []byte,
    urlPrefix string,
    metas map[string]string,
) ([]byte, error)

RenderDescriptionHTML will use similar logic as PostProcess, but will use a single special linkProcessor.

func RenderString Uses

func RenderString(filename string, raw, urlPrefix string, metas map[string]string) string

RenderString renders Markdown to HTML with special links and returns string type.

func RenderWiki Uses

func RenderWiki(filename string, rawBytes []byte, urlPrefix string, metas map[string]string) string

RenderWiki renders markdown wiki page to HTML and return HTML string

func ReplaceSanitizer Uses

func ReplaceSanitizer()

ReplaceSanitizer replaces the current sanitizer to account for changes in settings

func Sanitize Uses

func Sanitize(s string) string

Sanitize takes a string that contains a HTML fragment or document and applies policy whitelist.

func SanitizeBytes Uses

func SanitizeBytes(b []byte) []byte

SanitizeBytes takes a []byte slice that contains a HTML fragment or document and applies policy whitelist.

func Type Uses

func Type(filename string) string

Type returns if markup format via the filename

type Parser Uses

type Parser interface {
    Name() string // markup format name
    Extensions() []string
    Render(rawBytes []byte, urlPrefix string, metas map[string]string, isWiki bool) []byte
}

Parser defines an interface for parsering markup file to HTML

func GetParserByFileName Uses

func GetParserByFileName(filename string) Parser

GetParserByFileName get parser by filename

func GetParserByType Uses

func GetParserByType(tp string) Parser

GetParserByType returns a parser according type

type Sanitizer Uses

type Sanitizer struct {
    // contains filtered or unexported fields
}

Sanitizer is a protection wrapper of *bluemonday.Policy which does not allow any modification to the underlying policies once it's been created.

Directories

PathSynopsis
csv
external
markdown
mdstripper
orgmode

Package markup imports 18 packages (graph) and is imported by 33 packages. Updated 2019-11-13. Refresh now. Tools for package owners.