md

package
v0.1.165 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package md provides common markdown utilities, used by build-tools and learn platform.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy added in v0.1.127

func Copy(srcDir, destDir string) ([]string, error)

Copy copies the contents of the `src` directory to the `dest` directory. It skips over *.md files and returns their files names in a string slice, typically to generate HTML files from it.

func FindFiles added in v0.1.127

func FindFiles(root string) ([]string, error)

FindFiles finds recursively all file with .md extension in given directory and returns a slice of their names.

func HTMLFilename added in v0.1.127

func HTMLFilename(mdf string) string

HTMLFilename returns the HTML filename for a given markdown filename. README.md is converted to index.html, and all other .md files are converted .html file names with the same base name stem.

func RewriteLink(n Node)

RewriteLink replace a relative link to a .md file the HTML filename equivalent, see HTMLFilename.

func ToRoot added in v0.1.127

func ToRoot(filename string) string

ToRoot returns a relative path to the root of the given filename. It requires a final slash to be concatenated with further paths, so it can be used in templates more directly, e.g.:

<link rel="stylesheet" href="{{.Root}}/css/index.css" type="text/css" />

func Undecorate added in v0.1.161

func Undecorate(mdInline markdown.Inline) string

Undecorate returns a stripped down markdown representation of the given markdown.Inline: Strong has the `**` stripped, Code has the back-ticks stripped, Link only uses the text representation, no URL etc. Undecorate is used to extract a plain "name" for given inline elements.

func Walk

func Walk(node Node, f func(Node))

Walk visits a markdown AST node, executes function f on it and recursively visits all children.

Types

type Node

type Node interface{}

Node should be either a markdown.Block or markdown.Inline interface for the Walk function to take effect.

Jump to

Keyboard shortcuts

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