formatcore

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2023 License: MIT Imports: 7 Imported by: 1

README

formatcore

import "github.com/princjef/gomarkdoc/format/formatcore"

Package formatcore provides utilities for creating formatters like those found in the format package.

Index

func Anchor

func Anchor(anchor string) string

Anchor produces an anchor for the provided link.

func AnchorHeader

func AnchorHeader(level int, text, anchor string) (string, error)

AnchorHeader converts the provided text and custom anchor link into a header of the provided level. The level is expected to be at least 1.

func Bold

func Bold(text string) string

Bold converts the provided text to bold

func CodeBlock

func CodeBlock(code string) string

CodeBlock wraps the provided code as a code block. Language syntax highlighting is not supported.

func Escape

func Escape(text string) string

Escape escapes the special characters in the provided text, but leaves URLs found intact. Note that the URLs included must begin with a scheme to skip the escaping.

func GFMAccordion

func GFMAccordion(title, body string) string

GFMAccordion generates a collapsible content. The accordion's visible title while collapsed is the provided title and the expanded content is the body.

func GFMAccordionHeader

func GFMAccordionHeader(title string) string

GFMAccordionHeader generates the header visible when an accordion is collapsed.

The GFMAccordionHeader is expected to be used in conjunction with GFMAccordionTerminator() when the demands of the body's rendering requires it to be generated independently. The result looks conceptually like the following:

accordion := GFMAccordionHeader("Accordion Title") + "Accordion Body" + GFMAccordionTerminator()

func GFMAccordionTerminator

func GFMAccordionTerminator() string

GFMAccordionTerminator generates the code necessary to terminate an accordion after the body. It is expected to be used in conjunction with GFMAccordionHeader(). See GFMAccordionHeader for a full description.

func GFMCodeBlock

func GFMCodeBlock(language, code string) string

GFMCodeBlock wraps the provided code as a code block and tags it with the provided language (or no language if the empty string is provided), using the triple backtick format from GitHub Flavored Markdown.

func Header

func Header(level int, text string) (string, error)

Header converts the provided text into a header of the provided level. The level is expected to be at least 1.

func Link(text, href string) string

Link generates a link with the given text and href values.

func ListEntry

func ListEntry(depth int, text string) string

ListEntry generates an unordered list entry with the provided text at the provided zero-indexed depth. A depth of 0 is considered the topmost level of list.

func PlainText

func PlainText(text string) string

PlainText converts a markdown string to the plain text that appears in the rendered output.

Generated by gomarkdoc

Documentation

Overview

Package formatcore provides utilities for creating formatters like those found in the format package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Anchor added in v1.0.0

func Anchor(anchor string) string

Anchor produces an anchor for the provided link.

func AnchorHeader added in v1.0.0

func AnchorHeader(level int, text, anchor string) (string, error)

AnchorHeader converts the provided text and custom anchor link into a header of the provided level. The level is expected to be at least 1.

func Bold

func Bold(text string) string

Bold converts the provided text to bold

func CodeBlock

func CodeBlock(code string) string

CodeBlock wraps the provided code as a code block. Language syntax highlighting is not supported.

func Escape

func Escape(text string) string

Escape escapes the special characters in the provided text, but leaves URLs found intact. Note that the URLs included must begin with a scheme to skip the escaping.

func GFMAccordion

func GFMAccordion(title, body string) string

GFMAccordion generates a collapsible content. The accordion's visible title while collapsed is the provided title and the expanded content is the body.

func GFMAccordionHeader

func GFMAccordionHeader(title string) string

GFMAccordionHeader generates the header visible when an accordion is collapsed.

The GFMAccordionHeader is expected to be used in conjunction with GFMAccordionTerminator() when the demands of the body's rendering requires it to be generated independently. The result looks conceptually like the following:

accordion := GFMAccordionHeader("Accordion Title") + "Accordion Body" + GFMAccordionTerminator()

func GFMAccordionTerminator

func GFMAccordionTerminator() string

GFMAccordionTerminator generates the code necessary to terminate an accordion after the body. It is expected to be used in conjunction with GFMAccordionHeader(). See GFMAccordionHeader for a full description.

func GFMCodeBlock

func GFMCodeBlock(language, code string) string

GFMCodeBlock wraps the provided code as a code block and tags it with the provided language (or no language if the empty string is provided), using the triple backtick format from GitHub Flavored Markdown.

func Header(level int, text string) (string, error)

Header converts the provided text into a header of the provided level. The level is expected to be at least 1.

func Link(text, href string) string

Link generates a link with the given text and href values.

func ListEntry

func ListEntry(depth int, text string) string

ListEntry generates an unordered list entry with the provided text at the provided zero-indexed depth. A depth of 0 is considered the topmost level of list.

func PlainText

func PlainText(text string) string

PlainText converts a markdown string to the plain text that appears in the rendered output.

Types

This section is empty.

Jump to

Keyboard shortcuts

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