markdown

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package markdown is a small, dependency-free Markdown renderer.

It parses a constrained subset of Markdown — enough for project docs and website content — and emits HTML directly. It is not CommonMark-strict; the goal is predictable output for the inputs we actually write, not edge-case fidelity.

Supported block elements:

  • ATX headings (#, ##, … up to ######)
  • Paragraphs
  • Fenced code blocks (``` with optional language tag)
  • Unordered lists (-, *, +)
  • Ordered lists (1., 2., …)
  • Blockquotes (>)
  • Horizontal rules (---, ***, ___)
  • GFM-style tables (| col | col |)
  • YAML-ish frontmatter (--- key: value --- at the top of the document)

Supported inline elements:

  • Bold (**…** or __…__)
  • Italic (*…* or _…_)
  • Inline code (`…`)
  • Links ([text](url)) and images (![alt](url))

HTML in source is escaped, never passed through. Code blocks and inline code are rendered without syntax highlighting; callers can post-process if they want highlighted output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderHTML

func RenderHTML(input string) render.HTML

RenderHTML is a convenience wrapper that returns just the HTML body.

Types

type Document

type Document struct {
	// Frontmatter holds key/value pairs from a leading `--- ... ---` block.
	// Values are kept as raw strings; callers do their own typing.
	Frontmatter map[string]string

	// HTML is the rendered body.
	HTML render.HTML

	// Title is the text of the first H1 in the document if present, otherwise
	// the value of the `title` frontmatter key. Useful for setting <title>.
	Title string
}

Document is the result of parsing a Markdown source.

func Render

func Render(input string) Document

Render parses Markdown source and returns the rendered Document.

Jump to

Keyboard shortcuts

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