mdconv

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package mdconv converts an extracted article node to GitHub-Flavored Markdown. Before conversion it rewrites the node's links and images through caller callbacks, so a site build can point internal links at local files or in-file anchors and the image policy can localise pictures. After conversion it tidies the Markdown: no blank-line runs, a single trailing newline.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(node *html.Node, opts Options) (string, error)

Convert rewrites node's references and renders it to Markdown. The node is mutated in place by the rewrite, which is fine because it is a per-page copy.

func Tidy

func Tidy(md string) string

Tidy normalises converted Markdown: it trims trailing spaces, collapses runs of blank lines to one, and ends the document with exactly one newline.

Types

type Options

type Options struct {
	// Base resolves relative href and src values to absolute URLs before the
	// rewrite callbacks see them.
	Base *url.URL
	// RewriteLink maps an absolute link URL to the target written into the
	// Markdown. A nil callback, or an empty return, leaves the link as the
	// absolute URL.
	RewriteLink func(abs string) string
	// RewriteImage maps an absolute image URL (with its alt text) to the target
	// written into the Markdown. A nil callback, or an empty return, leaves the
	// image as the absolute URL.
	RewriteImage func(abs, alt string) string
}

Options configure one conversion.

Jump to

Keyboard shortcuts

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