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 ¶
- Variables
- func FirstHeading(doc ast.Node, src []byte) string
- func Lines(n ast.Node, src []byte) []string
- func LocalPath(dest, docPath string) (rel string, ok bool)
- func Parse(src []byte) (ast.Node, []byte)
- func PlainText(n ast.Node, src []byte) string
- func TextOf(n *ast.Text, src []byte) []byte
- func Unescape(v []byte) []byte
- type Math
- type MathBlock
- type Picture
Constants ¶
This section is empty.
Variables ¶
var KindMath = ast.NewNodeKind("Math")
KindMath is an inline formula's kind.
var KindMathBlock = ast.NewNodeKind("MathBlock")
KindMathBlock is a displayed formula's kind.
Functions ¶
func FirstHeading ¶
FirstHeading is the plain text of the document's first heading, or "".
func LocalPath ¶
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 ¶
Parse parses src as GitHub-flavoured Markdown, without its front matter. It returns the document and the source its nodes point into.
func PlainText ¶
PlainText is the text of a node's inlines, without formatting; raw HTML is left out.
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.
type MathBlock ¶
MathBlock is a displayed formula: $$ on its own line, the LaTeX, $$.
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 ¶
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.