markdown

package
v0.9.13 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package markdown parses Markdown the way Blitz's exporters read it (GitHub-flavoured, by goldmark, with $…$ and $$…$$ maths, a leading YAML front matter dropped, as the desktop preview reads it) and gives the plain text of its nodes, for the PDF and Word writers alike.

Index

Constants

This section is empty.

Variables

View Source
var KindMath = ast.NewNodeKind("Math")

KindMath is an inline formula's kind.

View Source
var KindMathBlock = ast.NewNodeKind("MathBlock")

KindMathBlock is a displayed formula's kind.

Functions

func FirstHeading

func FirstHeading(doc ast.Node, src []byte) string

FirstHeading is the plain text of the document's first heading, or "".

func Lines

func Lines(n ast.Node, src []byte) []string

Lines is a block's lines (a code block's), without the final newline.

func LocalPath

func LocalPath(dest, docPath string) (rel string, ok bool)

LocalPath is where a picture or link written dest in the document at docPath (workspace-relative, with "/") points in the workspace, as the desktop app's preview resolves it (files/mdlinks.ts): percent-escapes decoded, a query and a fragment dropped, a leading "/" from the workspace's root, else from the document's folder. ok is false for a URL (http:, data:, …), a fragment alone, or a path that leaves the workspace.

func Parse

func Parse(src []byte) (ast.Node, []byte)

Parse parses src as GitHub-flavoured Markdown, without its front matter. It returns the document and the source its nodes point into.

func PlainText

func PlainText(n ast.Node, src []byte) string

PlainText is the text of a node's inlines, without formatting; raw HTML is left out.

func TextOf

func TextOf(n *ast.Text, src []byte) []byte

TextOf is a text node's text, unescaped unless it's raw.

func Unescape

func Unescape(v []byte) []byte

Unescape resolves backslash escapes and character references, as an HTML renderer would.

Types

type Math

type Math struct {
	ast.BaseInline
	Source  string
	Display bool
}

Math is a formula in a paragraph: its LaTeX, and whether it was written $$…$$ (displayed) in the paragraph's text.

func (*Math) Dump

func (n *Math) Dump(src []byte, level int)

Dump implements ast.Node.

func (*Math) Kind

func (n *Math) Kind() ast.NodeKind

Kind implements ast.Node.

type MathBlock

type MathBlock struct {
	ast.BaseBlock
	Source string
	// contains filtered or unexported fields
}

MathBlock is a displayed formula: $$ on its own line, the LaTeX, $$.

func (*MathBlock) Dump

func (n *MathBlock) Dump(src []byte, level int)

Dump implements ast.Node.

func (*MathBlock) IsRaw

func (n *MathBlock) IsRaw() bool

IsRaw implements ast.Node: its lines are LaTeX, not Markdown.

func (*MathBlock) Kind

func (n *MathBlock) Kind() ast.NodeKind

Kind implements ast.Node.

type Picture

type Picture struct {
	Src, Alt string
	// Width is its width in pixels when the tag gives one, else 0.
	Width int
}

Picture is a picture written as HTML.

func HTMLPicture

func HTMLPicture(html string) (Picture, bool)

HTMLPicture is the picture in html when it's nothing but one <img> tag, as the preview shows one (raw HTML is otherwise left out): its src, alt and width.

Jump to

Keyboard shortcuts

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