markdown

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package markdown checks authored Markdown against the allowlist in docs/comment-format.md, so a body or summary cannot restructure the <details> wrapper the renderer puts around it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(text string, kind Kind, fix string) error

Check is a line scanner, not a parser: it refuses some Markdown GitHub would render in exchange for staying small and predictable.

func FindingIDs

func FindingIDs(text string, kind Kind, retry string) error

FindingIDs refuses text that cites a finding id outside a fence or a URL. Every round numbers its findings from f-001, so an id read from an earlier round names another finding in this one, and the review's reader can resolve neither. Fences are read as Check reads them, so text should pass Check first. retry ends the fix.

func IsMarkdownPath

func IsMarkdownPath(p string) bool

IsMarkdownPath reports whether a heading anchor applies to path.

func MapSummaryLines

func MapSummaryLines(text string, fn func(string) string) string

MapSummaryLines applies fn to each line that opens a <summary>, reading fences and HTML blocks as Check does, so a line that is fence content stays as written.

func NormalizeHeading

func NormalizeHeading(s string) string

NormalizeHeading trims a heading's text and reads each inner run of whitespace as one space, so a heading anchor matches however the file spaces it.

func OneDisclosure

func OneDisclosure(src string) error

OneDisclosure reports why text is not exactly one disclosure: it MUST open with a <details> tag, close with the matching </details> at its end, and hold every <details> inside paired and nested. Only tags GitHub passes through as HTML count, so a tag in a code span, in fenced or indented code, or in an HTML comment is text. It checks generated text, which may carry tags Check refuses, such as a summary's <b>.

It parses with goldmark, while GitHub renders with cmark-gfm. Both follow CommonMark with the same GFM extensions, but they are separate parsers, so where they disagree this reads the text as goldmark does.

func OpenDetails

func OpenDetails(text string) string

OpenDetails rewrites each <details> tag line to <details open>, reading fences and HTML blocks as Check does, so a <details> that is fence content stays as written.

func StructuralLines

func StructuralLines(text string) (lines []string, structural []bool)

StructuralLines reports which lines of text, split after normalizing line endings, are non-blank lines outside a fence, read as Check reads them. Authored text that passed Check holds no HTML comment on such a line, so a comment line loupe generated can be found by it without mistaking a fenced copy for the original.

func TitleFindingIDs

func TitleFindingIDs(title, retry string) error

TitleFindingIDs is FindingIDs for a title, which is one escaped paragraph: a backtick run there is text, not a fence, so nothing in a title is exempt but a URL.

Types

type Heading

type Heading struct {
	Text  string `json:"heading"`
	Level int    `json:"level"`
	Line  int    `json:"line"`
}

Heading is one heading of a Markdown file, as the run's outline stores it and a refusal lists it.

func Headings

func Headings(src []byte) []Heading

Headings lists the ATX headings at the top level of src, in file order. A heading inside a fence, an indented block, a block quote, a list item or YAML front matter does not count, since goldmark nests the first four and the front matter is blanked before the parse. A leading byte order mark is dropped, as GitHub's renderer drops it; it holds no newline, so line numbers stay the same.

type Kind

type Kind int
const (
	Body Kind = iota
	Summary
	// Note is a sticky round's note, which sits at the summary's depth.
	Note
	Impact
	SuggestedFix
	Message
	// WithdrawReason is a withdrawn finding's reason, which sits at the body's depth.
	WithdrawReason
	// Proposal is a finding's code-change suggestion on a local run, at the body's depth.
	Proposal
	// AcceptNote is a human's accept note on a decision, at the body's depth.
	AcceptNote
	// ExcludeReason is a human's exclude reason on a decision, at the body's depth.
	ExcludeReason
	// RunTitle is a local run's title, at the body's depth.
	RunTitle
	// Applier is a local run's applier name, at the body's depth.
	Applier
	// ReturnNote is the human's closing note when they return a local run, at the body's depth.
	ReturnNote
	// RiskReason is one reason for the reviewer's risk tier, a list item in the review's context block.
	RiskReason
)

Each kind names the field a refusal reports. A finding's impact and suggested fix sit at the body's depth, and the human's message at the confirmation sits at the summary's.

Jump to

Keyboard shortcuts

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