Documentation
¶
Overview ¶
Package mdrender renders the dictionary-neutral Entry IR as Markdown.
It is a sibling of internal/bobadapter, not a layer on top of it:
EntrySet → bobadapter → Bob toDict EntrySet → mdrender → Markdown
Both read the same canonical IR and neither can see the other. That is the whole point of the arrangement. Markdown is not produced by converting entry HTML — a second semantic path would drift from the parser the moment either changed — and the parser needs no knowledge that Markdown exists.
The renderer has two callers: deterministic diagnostics, which keep per-process resource URLs out, and user presentation, which enables resolved loopback audio/image links without enabling parser provenance.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Escape ¶
Escape exposes the renderer's escaping to tooling that needs to look for IR text inside rendered output. Re-implementing it in the checker would let the two drift, and the check would then be testing the copy.
func NavigationTarget ¶
NavigationTarget exposes how a lookup target is written, for the same reason Escape is exposed. A navigation target is inside a code span, where Markdown syntax is already inert and escaping it would put literal backslashes on the page — so it is not escaped, and tooling must look for this form instead.
func RenderEntry ¶
RenderEntry renders one entry as a standalone document.
func RenderEntrySet ¶
RenderEntrySet renders a complete EntrySet, preserving record boundaries.
Distinct records are never merged: each keeps its own heading and its own ordinal, because two records under one key are two things the dictionary chose to say separately. No field of one record is ever interleaved with another's, in either mode.
Types ¶
type MultiRecordMode ¶
type MultiRecordMode string
MultiRecordMode selects how several records under one key are presented.
It mirrors the Bob adapter's option of the same name. The concept is shared — show one record, or show them all — but each surface expresses it with what it actually has. Bob has clickable related words; Markdown has a horizontal rule and no documented lookup action, so combined mode divides records with a thematic break and separate mode lists siblings as copyable query text.
const ( // MultiRecordCombined renders every record in canonical order, divided by // a Markdown thematic break. It is the default because a caller that has // not chosen — diagnostics above all — must see everything the parser // produced rather than one arbitrary record. MultiRecordCombined MultiRecordMode = "combined" // MultiRecordSeparate renders exactly one record plus sibling selectors. MultiRecordSeparate MultiRecordMode = "separate" )
type Options ¶
type Options struct {
IncludeExamples bool
IncludeExtras bool
MaxExamplesPerSense int
// AudioLinks writes the playable loopback URL for a resolved recording.
//
// It is off by default because those URLs carry a per-process resource
// token: including one would make the same EntrySet render differently on
// every run and destroy snapshot comparison. With it off, an available
// recording is still reported — just as a fact rather than as a link.
AudioLinks bool
// ImageLinks writes resolved inline MDD illustrations at their original
// prose position. It is disabled for deterministic diagnostic snapshots.
ImageLinks bool
// RecordOrdinal selects one visible record when a record selector was used.
// A non-zero value always wins over MultiRecordMode, because the user asked
// for that record by name.
RecordOrdinal int
// MultiRecordMode selects combined or separate presentation. Empty means
// combined.
MultiRecordMode MultiRecordMode
// IncludeProvenance annotates each structure with the parser rule that
// produced it. Development only; it is what makes a snapshot answer "which
// heuristic did this?".
IncludeProvenance bool
// IncludeGrammar preserves verbose linguistic rules (e.g. "[used in negatives]")
// in presentation. When false, they are omitted to reduce noise.
IncludeGrammar bool
}
Options configures rendering. The zero value renders senses only.
func DefaultOptions ¶
func DefaultOptions() Options
DefaultOptions renders a complete entry for a human reader.
func UserOptions ¶
func UserOptions() Options
UserOptions returns complete, user-facing Markdown. It intentionally does not enable IncludeProvenance: parser rules and confidence belong only in diagnostic artifacts.