mdparity

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package mdparity is the one grammar kb reduces a card description to before anything renders it. The web UI the TUI is at parity with froze a small Markdown subset, and both TUI surfaces that show a description - the card detail pane, which hands the reduced source to glamour, and the board card, which draws it at card scale itself - read that subset here rather than each carrying a recognizer of its own.

Two consumers, one grammar: a construct the pane understands and the card does not, or the reverse, is a fork of the product contract, which is what this package exists to make impossible.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parity

func Parity(source string) string

Parity reduces a description to the frozen web renderer's grammar before Glamour sees it. Glamour deliberately understands much more Markdown; neutralizing everything outside this allowlist keeps that extra syntax literal instead of quietly widening the product contract.

The grammar is per line and starts at column zero: a heading, a bullet or an ordinal is only ever the first thing on a line, indentation carries no meaning of its own, and no construct spans two lines except a fence. Every other line is prose. Neutralizing has to be invisible, which rules out the backslash for characters Glamour does not strip one from - see escapeMarkdown.

func TaskRefPattern

func TaskRefPattern() *regexp.Regexp

TaskRefPattern is the in-board reference matcher, exported for the pointer map that anchors a hit region on every rendered reference. The matcher and the grammar that decides a reference is an autolink are the same expression on purpose: a pane that linked a reference the map could not find, or found one the pane did not link, would be a fork.

Types

type Block

type Block struct {
	Kind   Kind
	Marker string
	Runs   []Run
}

Block is one reduced source line: its kind, the literal marker the grammar requires be kept (an ordinal, and nothing else), and its inline runs.

func Blocks

func Blocks(source string) []Block

Blocks reduces a description to the card-scale form of the frozen grammar: the same recognizers Parity feeds glamour, resolved into runs a renderer can style directly instead of into Markdown source.

The two forms differ only in their output. Parity has to hand glamour a document, so it escapes everything outside the grammar and spends a blank line between blocks; a card has neither the rows for blank lines nor a second parser to defend itself from, so it takes the runs. What each recognizes is the same code, which is the point of the package.

A blank source line yields no block: the card's row budget is small enough that spending one on nothing is a row of description the reader does not get.

type Emphasis

type Emphasis uint8

Emphasis is the inline treatment one run of a line carries.

const (
	// Plain is unemphasized prose.
	Plain Emphasis = iota
	// Strong is **bold**.
	Strong
	// Slant is *italic* or _italic_.
	Slant
	// Mono is a `code` span.
	Mono
	// Anchor is a link, an autolink or a kb task reference. The rendered text
	// is the label for an explicit link and the target itself otherwise; the
	// card has no width for a href beside its label.
	Anchor
)

type Kind

type Kind uint8

Kind is the block a source line reduced to under the frozen grammar. The board card draws each kind at card scale; the card detail pane reaches the same set through glamour. Spec section 3.3 (issue #232).

const (
	// Prose is any line the grammar does not claim as one of the others.
	Prose Kind = iota
	// Heading is a level 1-3 ATX heading. Its marker is not rendered.
	Heading
	// Bullet is a "- " list item. Its marker is a glyph the render site owns.
	Bullet
	// Ordered is an "N. " list item. Its marker is source text and is kept
	// literal: the frozen renderer preserves every ordinal rather than
	// renumbering runs of them.
	Ordered
	// Code is a line inside a fence. Nothing inside it is inline syntax.
	Code
)

type Run

type Run struct {
	Text     string
	Emphasis Emphasis
}

Run is one stretch of a line carrying a single emphasis.

Jump to

Keyboard shortcuts

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