markdown

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToMarkdown

func ToMarkdown(w io.Writer, text string, opts ...Option)

ToMarkdown converts comment text to formatted Markdown. The comment was prepared by DocReader, so it is known not to have leading, trailing blank lines nor to have trailing spaces at the end of lines. The comment markers have already been removed.

Each span of unindented non-blank lines is converted into a single paragraph. There is one exception to the rule: a span that consists of a single line, is followed by another paragraph span, begins with a capital letter, and contains no punctuation other than parentheses and commas is formatted as a heading.

A span of indented lines is converted into a <pre> block, with the common indent prefix removed.

URLs in the comment text are converted into links; if the URL also appears in the words map, the link is taken from the map (if the corresponding map value is the empty string, the URL is not converted into a link).

Types

type Option added in v1.4.0

type Option func(*options)

Option is option type for ToMarkdown

func OptNoDiff added in v1.4.0

func OptNoDiff(noDiffs bool) Option

OptNoDiff disables automatic marking of code blocks as diffs.

func OptWords added in v1.4.0

func OptWords(words map[string]string) Option

OptWords sets the list of known words. Go identifiers that appear in the words map are italicized; if the corresponding map value is not the empty string, it is considered a URL and the word is converted into a link.

Jump to

Keyboard shortcuts

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