markdown

package
v0.0.2 Latest Latest
Warning

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

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

Documentation

Overview

Package markdown provides on-demand CommonMark parsing utilities for OpenAPI description fields. It wraps goldmark to validate markdown structure, render hover previews, and extract structural information from descriptions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(source string) (string, error)

Render converts CommonMark source text to HTML. Useful for hover previews where the editor supports HTML rendering in MarkupContent.

func TranslatePosition

func TranslatePosition(desc openapi.DescriptionValue, goldmarkLine int) protocol.Range

TranslatePosition converts a goldmark 1-based line number into an absolute LSP range using the description's source location and geometry.

func TranslateRange

func TranslateRange(desc openapi.DescriptionValue, line, col, length int) protocol.Range

TranslateRange converts a goldmark position with column and length into a precise absolute LSP range. IndentCols is added to the column to account for block scalar indentation in the source file.

Types

type Heading

type Heading struct {
	Level int
	Text  string
	Line  int
}

Heading represents a parsed markdown heading.

func Headings

func Headings(source string) []Heading

Headings returns the heading texts and levels from a markdown description.

type Issue

type Issue struct {
	Line    int
	Message string
}

Issue describes a structural problem found in a markdown document.

func Validate

func Validate(source string) []Issue

Validate checks a CommonMark description for structural issues such as broken link references, empty headings, and skipped heading levels.

type Link struct {
	Destination string
	Text        string
	Line        int
	Column      int
	Length      int // length of the full markdown link syntax [text](dest)
}

Link represents a parsed markdown link.

func Links(source string) []Link

Links returns all link destinations found in a markdown description.

Jump to

Keyboard shortcuts

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