rendering

package
v0.0.0-...-ef83997 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package rendering contains all the functions used to render the information in Markup down or HTML format.

Index

Constants

View Source
const (
	// the key for the 'content' field when the MarkupContent is converted into/from a Map
	ContentKey = "content"
	// the key for the 'markup' field when the MarkupContent is converted into/from a Map
	MarkupKey = "markup"
)
View Source
const (
	// SystemMarkupDefault Default value
	SystemMarkupDefault = SystemMarkupPlainText
	// SystemMarkupPlainText plain text
	SystemMarkupPlainText = "PlainText"
	// SystemMarkupMarkdown Markdown
	SystemMarkupMarkdown = "Markdown"
	// SystemMarkupJiraWiki JIRA Wiki
	SystemMarkupJiraWiki = "JiraWiki"
)

Variables

This section is empty.

Functions

func IsMarkupSupported

func IsMarkupSupported(markup string) bool

IsMarkupSupported indicates if the given markup is supported

func MarkdownCommonHighlighter

func MarkdownCommonHighlighter(input []byte) []byte

MarkdownCommonHighlighter uses the blackfriday.MarkdownCommon setup but also includes code-prettify formatting of BlockCode segments

func NilSafeGetMarkup

func NilSafeGetMarkup(markup *string) string

NilSafeGetMarkup returns the given markup if it is not nil nor empty, otherwise it returns the default markup

func RenderMarkupToHTML

func RenderMarkupToHTML(content, markup string) string

RenderMarkupToHTML converts the given `content` in HTML using the markup tool corresponding to the given `markup` argument or return nil if no tool for the given `markup` is available, or returns an `error` if the command was not found or failed.

Types

type MarkupContent

type MarkupContent struct {
	Content string `json:"content"`
	Markup  string `json:"markup"`
}

MarkupContent defines the raw content of a field along with the markup language used to input the content.

func NewMarkupContent

func NewMarkupContent(content, markup string) MarkupContent

NewMarkupContent creates a MarkupContent from the given content, using the default markup.

func NewMarkupContentFromLegacy

func NewMarkupContentFromLegacy(content string) MarkupContent

NewMarkupContentFromLegacy creates a MarkupContent from the given content, using the default markup.

func NewMarkupContentFromMap

func NewMarkupContentFromMap(value map[string]interface{}) MarkupContent

NewMarkupContentFromMap creates a MarkupContent from the given Map, filling the 'Markup' field with the default value if no entry was found in the input or if the given markup is not supported. This avoids filling the DB with invalid markup types.

func NewMarkupContentFromValue

func NewMarkupContentFromValue(value interface{}) *MarkupContent

NewMarkupContentFromValue creates a MarkupContent from the given value, by converting a 'string', a 'map[string]interface{}' or casting a 'MarkupContent'. Otherwise, it returns nil.

func (*MarkupContent) ToMap

func (markupContent *MarkupContent) ToMap() map[string]interface{}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL