markup

package
v0.0.0-...-8df494d Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: GPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const CODE_TABWIDTH = 4
View Source
const FM_SEPARATOR = "---"
View Source
const NO_SYNTAX_HIGHLIGHTING = ""

Variables

View Source
var SKIP_TAGS = []string{"pre", "code", "kbd", "script", "math"}
View Source
var SUPPORTED_MINIFIERS = []string{".css", ".html", ".js", ".xml"}

Functions

func EvalExpression

func EvalExpression(engine *Engine, expression string, context map[string]interface{}) (string, error)

func ExtractFirstParagraph

func ExtractFirstParagraph(htmlReader io.Reader) string

Find the first p tag in the given html document and return its text content.

func InjectScript

func InjectScript(htmlReader io.Reader, jsCode string) (io.Reader, error)

Inject a <script> tag with the given JavaScript code into provided the HTML document and return the updated document as a new io.Reader

func Smartify

func Smartify(extension string, contentReader io.Reader) (io.Reader, error)

Types

type Engine

type Engine = liquid.Engine

func NewEngine

func NewEngine(siteUrl string, includesDir string) *Engine

Create a new template engine, with custom liquid filters. The `siteUrl` is necessary to provide context for the absolute_url filter.

type Minifier

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

func LoadMinifier

func LoadMinifier(exclusions []string) Minifier

func (*Minifier) Minify

func (m *Minifier) Minify(path string, contentReader io.Reader) io.Reader

type Template

type Template struct {
	SrcPath  string
	Metadata map[string]interface{}
	// contains filtered or unexported fields
}

func Parse

func Parse(engine *Engine, path string) (*Template, error)

Try to parse a liquid template at the given location. Files starting with front matter (--- sorrrounded yaml) are considered templates. If the given file is not headed by front matter return (nil, nil). The front matter contents are stored in the returned template's Metadata.

func (Template) IsDraft

func (templ Template) IsDraft() bool

func (Template) IsPost

func (templ Template) IsPost() bool

func (Template) Render

func (templ Template) Render() ([]byte, error)

Renders the liquid template with default bindings.

func (Template) RenderWith

func (templ Template) RenderWith(context map[string]interface{}, hlTheme string) ([]byte, error)

Renders the liquid template with the given context as bindings. If the template source is org or md, convert them to html after the liquid rendering.

func (Template) SrcExt

func (templ Template) SrcExt() string

Return the extension of this template's source file.

func (Template) TargetExt

func (templ Template) TargetExt() string

Return the extension for the output format of this template

Jump to

Keyboard shortcuts

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