Documentation
¶
Overview ¶
Package marksplice provides structured GitHub Flavored Markdown creation and source-preserving manipulation.
Marksplice is currently pre-v1 beta software under active development. Public APIs may change incompatibly between v0 releases until a stable v1 contract is explicitly published.
Marksplice exposes reviewed new-document construction, snapshot-scoped structural views, copied bounded source reads, and named source-preserving mutations while keeping Goldmark and lossless source-mapping implementation details internal.
Index ¶
- Variables
- type AutoLink
- type Blockquote
- type ChangeSet
- type CodeSpan
- type Document
- func (d *Document) AutoLink(id NodeID) (AutoLink, bool)
- func (d *Document) Blockquote(id NodeID) (Blockquote, bool)
- func (d *Document) CodeSpan(id NodeID) (CodeSpan, bool)
- func (d *Document) Emphasis(id NodeID) (Emphasis, bool)
- func (d *Document) FencedCode(id NodeID) (FencedCode, bool)
- func (d *Document) FrontMatterField(id NodeID) (FrontMatterField, bool)
- func (d *Document) HTMLAnchor(id NodeID) (HTMLAnchor, bool)
- func (d *Document) HTMLComment(id NodeID) (HTMLComment, bool)
- func (d *Document) Heading(id NodeID) (Heading, bool)
- func (d *Document) Image(id NodeID) (Image, bool)
- func (d *Document) InlineLink(id NodeID) (InlineLink, bool)
- func (d *Document) ListItem(id NodeID) (ListItem, bool)
- func (d *Document) Node(id NodeID) (Node, bool)
- func (d *Document) Nodes() []Node
- func (d *Document) Paragraph(id NodeID) (Paragraph, bool)
- func (d *Document) PrepareAppendListItemChild(parentID NodeID, fragment []byte) (ChangeSet, error)
- func (d *Document) PrepareAppendSectionChild(parentHeadingID NodeID, fragment []byte) (ChangeSet, error)
- func (d *Document) PrepareAppendTableRow(id NodeID, fragment []byte) (ChangeSet, error)
- func (d *Document) PrepareInsertListItemAfter(anchorID NodeID, fragment []byte) (ChangeSet, error)
- func (d *Document) PrepareInsertListItemBefore(anchorID NodeID, fragment []byte) (ChangeSet, error)
- func (d *Document) PrepareInsertSectionAfter(headingID NodeID, fragment []byte) (ChangeSet, error)
- func (d *Document) PrepareInsertSectionBefore(headingID NodeID, fragment []byte) (ChangeSet, error)
- func (d *Document) PrepareInsertTableColumn(id NodeID, column int, header []byte, alignment TableAlignment, body [][]byte) (ChangeSet, error)
- func (d *Document) PrepareInsertTableRowAfter(anchorID NodeID, fragment []byte) (ChangeSet, error)
- func (d *Document) PrepareInsertTableRowBefore(anchorID NodeID, fragment []byte) (ChangeSet, error)
- func (d *Document) PrepareMoveListItemAfter(id, anchorID NodeID) (ChangeSet, error)
- func (d *Document) PrepareMoveListItemBefore(id, anchorID NodeID) (ChangeSet, error)
- func (d *Document) PrepareMoveSectionAfter(headingID, anchorHeadingID NodeID) (ChangeSet, error)
- func (d *Document) PrepareMoveSectionBefore(headingID, anchorHeadingID NodeID) (ChangeSet, error)
- func (d *Document) PrepareMoveTableColumn(id NodeID, from, to int) (ChangeSet, error)
- func (d *Document) PrepareMoveTableRowAfter(id, anchorID NodeID) (ChangeSet, error)
- func (d *Document) PrepareMoveTableRowBefore(id, anchorID NodeID) (ChangeSet, error)
- func (d *Document) PrepareRemoveBlockquote(id NodeID) (ChangeSet, error)
- func (d *Document) PrepareRemoveListItem(id NodeID) (ChangeSet, error)
- func (d *Document) PrepareRemoveSection(headingID NodeID) (ChangeSet, error)
- func (d *Document) PrepareRemoveTableColumn(id NodeID, column int) (ChangeSet, error)
- func (d *Document) PrepareRemoveTableRow(id NodeID) (ChangeSet, error)
- func (d *Document) PrepareRemoveThematicBreak(id NodeID) (ChangeSet, error)
- func (d *Document) PrepareRenameHeading(id NodeID, replacement []byte) (ChangeSet, error)
- func (d *Document) PrepareReplaceAutoLink(id NodeID, replacement []byte) (ChangeSet, error)
- func (d *Document) PrepareReplaceCodeSpan(id NodeID, replacement []byte) (ChangeSet, error)
- func (d *Document) PrepareReplaceEmphasis(id NodeID, replacement []byte) (ChangeSet, error)
- func (d *Document) PrepareReplaceFencedCode(id NodeID, replacement []byte) (ChangeSet, error)
- func (d *Document) PrepareReplaceFrontMatterValue(id NodeID, replacement []byte) (ChangeSet, error)
- func (d *Document) PrepareReplaceHTMLAnchor(id NodeID, replacement []byte) (ChangeSet, error)
- func (d *Document) PrepareReplaceHTMLComment(id NodeID, replacement []byte) (ChangeSet, error)
- func (d *Document) PrepareReplaceImageDestination(id NodeID, replacement []byte) (ChangeSet, error)
- func (d *Document) PrepareReplaceInlineLinkDestination(id NodeID, replacement []byte) (ChangeSet, error)
- func (d *Document) PrepareReplaceListItem(id NodeID, replacement []byte) (ChangeSet, error)
- func (d *Document) PrepareReplaceListItemSubtree(id NodeID, replacement []byte) (ChangeSet, error)
- func (d *Document) PrepareReplaceParagraph(id NodeID, replacement []byte) (ChangeSet, error)
- func (d *Document) PrepareReplaceReferenceDefinitionDestination(id NodeID, replacement []byte) (ChangeSet, error)
- func (d *Document) PrepareReplaceSection(headingID NodeID, replacement []byte) (ChangeSet, error)
- func (d *Document) PrepareReplaceSectionBody(headingID NodeID, replacement []byte) (ChangeSet, error)
- func (d *Document) PrepareReplaceStrikethrough(id NodeID, replacement []byte) (ChangeSet, error)
- func (d *Document) PrepareReplaceStrong(id NodeID, replacement []byte) (ChangeSet, error)
- func (d *Document) PrepareReplaceTableCell(id NodeID, replacement []byte) (ChangeSet, error)
- func (d *Document) PrepareReplaceTableRow(id NodeID, replacement []byte) (ChangeSet, error)
- func (d *Document) PrepareSetTableAlignments(id NodeID, alignments []TableAlignment) (ChangeSet, error)
- func (d *Document) PrepareSetTableColumnAlignment(id NodeID, column int, alignment TableAlignment) (ChangeSet, error)
- func (d *Document) PrepareSetTaskChecked(id NodeID, checked bool) (ChangeSet, error)
- func (d *Document) ReferenceDefinition(id NodeID) (ReferenceDefinition, bool)
- func (d *Document) Section(headingID NodeID) (Section, bool)
- func (d *Document) SectionChildHeadingIDs(headingID NodeID) ([]NodeID, bool)
- func (d *Document) Sections() []Section
- func (d *Document) SourceRange(range_ Range) ([]byte, bool)
- func (d *Document) Strikethrough(id NodeID) (Strikethrough, bool)
- func (d *Document) Strong(id NodeID) (Strong, bool)
- func (d *Document) Table(id NodeID) (Table, bool)
- func (d *Document) TableAlignments(tableID NodeID) ([]TableAlignment, bool)
- func (d *Document) TableCell(id NodeID) (TableCell, bool)
- func (d *Document) TableHeaderCellIDs(tableID NodeID) ([]NodeID, bool)
- func (d *Document) TableRow(id NodeID) (TableRow, bool)
- func (d *Document) TableRowAlignments(rowID NodeID) ([]TableAlignment, bool)
- func (d *Document) TableRowCellIDs(rowID NodeID) ([]NodeID, bool)
- func (d *Document) TableRowHeaderCellIDs(rowID NodeID) ([]NodeID, bool)
- func (d *Document) TableRowIDs(tableID NodeID) ([]NodeID, bool)
- func (d *Document) Task(id NodeID) (Task, bool)
- func (d *Document) ThematicBreak(id NodeID) (ThematicBreak, bool)
- type DocumentBuilder
- func (b *DocumentBuilder) AppendBlockquote(inlineGFM string) error
- func (b *DocumentBuilder) AppendBlockquoteBlocks(depth int, content *DocumentBuilder) error
- func (b *DocumentBuilder) AppendBlockquoteContent(content ...Inline) error
- func (b *DocumentBuilder) AppendFencedCode(content, info string) error
- func (b *DocumentBuilder) AppendHeading(level int, inlineGFM string) error
- func (b *DocumentBuilder) AppendHeadingContent(level int, content ...Inline) error
- func (b *DocumentBuilder) AppendNestedBlockquote(depth int, inlineGFM string) error
- func (b *DocumentBuilder) AppendNestedBlockquoteContent(depth int, content ...Inline) error
- func (b *DocumentBuilder) AppendNestedOrderedList(items ...ListItemInput) error
- func (b *DocumentBuilder) AppendNestedOrderedTaskList(items ...TaskListItemInput) error
- func (b *DocumentBuilder) AppendNestedUnorderedList(items ...ListItemInput) error
- func (b *DocumentBuilder) AppendNestedUnorderedTaskList(items ...TaskListItemInput) error
- func (b *DocumentBuilder) AppendOrderedList(items ...string) error
- func (b *DocumentBuilder) AppendOrderedTaskList(items ...TaskListItem) error
- func (b *DocumentBuilder) AppendParagraph(inlineGFM string) error
- func (b *DocumentBuilder) AppendParagraphContent(content ...Inline) error
- func (b *DocumentBuilder) AppendReferenceDefinition(label, destination string) error
- func (b *DocumentBuilder) AppendReferenceDefinitionWithTitle(label, destination, title string) error
- func (b *DocumentBuilder) AppendTable(header []string, rows ...[]string) error
- func (b *DocumentBuilder) AppendTableWithAlignments(header []string, alignments []TableAlignment, rows ...[]string) error
- func (b *DocumentBuilder) AppendThematicBreak() error
- func (b *DocumentBuilder) AppendUnorderedList(items ...string) error
- func (b *DocumentBuilder) AppendUnorderedTaskList(items ...TaskListItem) error
- func (b *DocumentBuilder) Markdown() ([]byte, error)
- func (b *DocumentBuilder) SetTOMLFrontMatter(fields ...FrontMatterFieldInput) error
- func (b *DocumentBuilder) SetYAMLFrontMatter(fields ...FrontMatterFieldInput) error
- type Emphasis
- type FencedCode
- type FrontMatterField
- type FrontMatterFieldInput
- type FrontMatterFormat
- type HTMLAnchor
- type HTMLAnchorAttribute
- type HTMLComment
- type Heading
- type HeadingStyle
- type Image
- type Inline
- func AutoLinkInline(value string) Inline
- func CodeInline(code string) Inline
- func EmphasisInline(content ...Inline) Inline
- func ImageInline(destination string, alt ...Inline) Inline
- func ImageInlineWithTitle(destination, title string, alt ...Inline) Inline
- func LinkInline(destination string, label ...Inline) Inline
- func LinkInlineWithTitle(destination, title string, label ...Inline) Inline
- func ReferenceImageInline(reference string, alt ...Inline) Inline
- func ReferenceLinkInline(reference string, label ...Inline) Inline
- func StrikethroughInline(content ...Inline) Inline
- func StrongInline(content ...Inline) Inline
- func TextInline(text string) Inline
- type InlineLink
- type Kind
- type ListItem
- type ListItemInput
- type Node
- type NodeID
- type Paragraph
- type Range
- type ReferenceDefinition
- type Section
- type Strikethrough
- type Strong
- type Table
- type TableAlignment
- type TableCell
- type TableRow
- type Task
- type TaskListItem
- type TaskListItemInput
- type ThematicBreak
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNodeNotFound reports that a snapshot-local node ID does not exist. ErrNodeNotFound = errors.New("node not found") // ErrInvalidReplacement reports a requested mutation that cannot preserve the required structure. ErrInvalidReplacement = errors.New("invalid replacement") // ErrInvalidTargetKind reports that an operation does not support the targeted node kind. ErrInvalidTargetKind = errors.New("invalid target kind") // ErrSourceConflict reports that a prepared change was applied to a different source snapshot. ErrSourceConflict = errors.New("source snapshot conflict") // ErrInvalidConstruction reports new-document content that cannot be proven to produce the requested GFM structure. ErrInvalidConstruction = errors.New("invalid construction") )
Functions ¶
This section is empty.
Types ¶
type AutoLink ¶
type AutoLink struct {
// contains filtered or unexported fields
}
AutoLink is immutable typed detail for one promoted single-line GFM autolink.
type Blockquote ¶
type Blockquote struct {
// contains filtered or unexported fields
}
Blockquote is immutable typed detail for one promoted simple top-level blockquote.
func (Blockquote) ContentRange ¶
func (b Blockquote) ContentRange() Range
ContentRange returns the exact inner single-paragraph source span. Leading indentation, the '>' marker, its optional following space, and the line terminator are outside this range.
func (Blockquote) ID ¶
func (b Blockquote) ID() NodeID
ID returns the blockquote's snapshot-scoped node identity.
func (Blockquote) Range ¶
func (b Blockquote) Range() Range
Range returns the exact complete physical blockquote line owned by structural operations. When present, the line terminator is included.
type ChangeSet ¶
type ChangeSet struct {
// contains filtered or unexported fields
}
ChangeSet is an opaque prepared change bound to one exact source snapshot. Its zero value is unbound and Apply reports ErrSourceConflict.
type CodeSpan ¶
type CodeSpan struct {
// contains filtered or unexported fields
}
CodeSpan is immutable typed detail for one promoted simple single-line code span.
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
Document is an immutable parsed Markdown source snapshot.
func Parse ¶
Parse copies and parses source into an immutable document snapshot.
Example ¶
package main
import (
"fmt"
"github.com/zoster81/marksplice"
)
func main() {
source := []byte("# Title\n\nBody.\n")
document, err := marksplice.Parse(source)
if err != nil {
panic(err)
}
for _, node := range document.Nodes() {
if node.Kind() != marksplice.KindHeading {
continue
}
heading, ok := document.Heading(node.ID())
if !ok {
continue
}
content, ok := document.SourceRange(heading.Range())
if !ok {
panic("heading range is not readable")
}
fmt.Printf("level=%d text=%s\n", heading.Level(), content)
}
}
Output: level=1 text=Title
func (*Document) AutoLink ¶
AutoLink returns typed detail for one promoted single-line GFM autolink.
func (*Document) Blockquote ¶
func (d *Document) Blockquote(id NodeID) (Blockquote, bool)
Blockquote returns typed detail for one promoted simple top-level blockquote.
func (*Document) CodeSpan ¶
CodeSpan returns typed detail for one promoted simple single-line code span.
func (*Document) FencedCode ¶
func (d *Document) FencedCode(id NodeID) (FencedCode, bool)
FencedCode returns typed detail for one promoted supported fenced code block.
func (*Document) FrontMatterField ¶
func (d *Document) FrontMatterField(id NodeID) (FrontMatterField, bool)
FrontMatterField returns typed detail for one promoted simple leading YAML/TOML scalar field.
func (*Document) HTMLAnchor ¶
func (d *Document) HTMLAnchor(id NodeID) (HTMLAnchor, bool)
HTMLAnchor returns typed detail for one promoted simple quoted id/name attribute on an <a> tag.
func (*Document) HTMLComment ¶
func (d *Document) HTMLComment(id NodeID) (HTMLComment, bool)
HTMLComment returns typed detail for one promoted single-line HTML comment.
func (*Document) InlineLink ¶
func (d *Document) InlineLink(id NodeID) (InlineLink, bool)
InlineLink returns typed detail for one promoted simple inline link.
func (*Document) PrepareAppendListItemChild ¶
PrepareAppendListItemChild prepares appending one complete direct-child subtree to a fully supported list-item subtree.
func (*Document) PrepareAppendSectionChild ¶
func (d *Document) PrepareAppendSectionChild(parentHeadingID NodeID, fragment []byte) (ChangeSet, error)
PrepareAppendSectionChild prepares appending one direct child section subtree to a promoted parent section.
func (*Document) PrepareAppendTableRow ¶
PrepareAppendTableRow prepares appending one caller-owned compatible body row to a promoted GFM table.
func (*Document) PrepareInsertListItemAfter ¶
PrepareInsertListItemAfter prepares insertion of one complete same-shape supported list-item subtree immediately after a complete supported anchor subtree.
func (*Document) PrepareInsertListItemBefore ¶
PrepareInsertListItemBefore prepares insertion of one complete same-shape supported list-item subtree immediately before a complete supported anchor subtree.
func (*Document) PrepareInsertSectionAfter ¶
PrepareInsertSectionAfter prepares insertion of one sibling section subtree immediately after the target section subtree.
func (*Document) PrepareInsertSectionBefore ¶
PrepareInsertSectionBefore prepares insertion of one sibling section subtree immediately before the target section.
func (*Document) PrepareInsertTableColumn ¶
func (d *Document) PrepareInsertTableColumn(id NodeID, column int, header []byte, alignment TableAlignment, body [][]byte) (ChangeSet, error)
PrepareInsertTableColumn prepares source-preserving insertion of one complete promoted GFM table column.
func (*Document) PrepareInsertTableRowAfter ¶
PrepareInsertTableRowAfter prepares insertion of one complete compatible body row after a promoted row.
func (*Document) PrepareInsertTableRowBefore ¶
PrepareInsertTableRowBefore prepares insertion of one complete compatible body row before a promoted row.
func (*Document) PrepareMoveListItemAfter ¶
PrepareMoveListItemAfter prepares moving one complete supported list-item subtree immediately after a complete same-shape anchor subtree.
func (*Document) PrepareMoveListItemBefore ¶
PrepareMoveListItemBefore prepares moving one complete supported list-item subtree immediately before a complete same-shape anchor subtree.
func (*Document) PrepareMoveSectionAfter ¶
PrepareMoveSectionAfter prepares moving one complete promoted section subtree immediately after a same-level anchor subtree.
func (*Document) PrepareMoveSectionBefore ¶
PrepareMoveSectionBefore prepares moving one complete promoted section subtree immediately before a same-level anchor section.
func (*Document) PrepareMoveTableColumn ¶
PrepareMoveTableColumn prepares moving one complete promoted GFM table column to a new zero-based position.
func (*Document) PrepareMoveTableRowAfter ¶
PrepareMoveTableRowAfter prepares moving one complete body row after another promoted row in the same table.
func (*Document) PrepareMoveTableRowBefore ¶
PrepareMoveTableRowBefore prepares moving one complete body row before another promoted row in the same table.
func (*Document) PrepareRemoveBlockquote ¶
PrepareRemoveBlockquote prepares source-preserving removal of one complete promoted simple top-level blockquote line.
func (*Document) PrepareRemoveListItem ¶
PrepareRemoveListItem prepares removal of one complete supported list-item subtree.
func (*Document) PrepareRemoveSection ¶
PrepareRemoveSection prepares source-preserving removal of one complete promoted section subtree.
func (*Document) PrepareRemoveTableColumn ¶
PrepareRemoveTableColumn prepares source-preserving removal of one complete promoted GFM table column.
func (*Document) PrepareRemoveTableRow ¶
PrepareRemoveTableRow prepares source-preserving removal of one promoted GFM table body row.
func (*Document) PrepareRemoveThematicBreak ¶
PrepareRemoveThematicBreak prepares source-preserving removal of one complete promoted top-level thematic-break line.
func (*Document) PrepareRenameHeading ¶
PrepareRenameHeading prepares a source-preserving rename of promoted heading content.
Example ¶
package main
import (
"fmt"
"github.com/zoster81/marksplice"
)
func main() {
source := []byte("## Old title ##\n\nBody.\n")
document, err := marksplice.Parse(source)
if err != nil {
panic(err)
}
var heading marksplice.Heading
for _, node := range document.Nodes() {
if node.Kind() != marksplice.KindHeading {
continue
}
var ok bool
heading, ok = document.Heading(node.ID())
if ok {
break
}
}
change, err := document.PrepareRenameHeading(heading.ID(), []byte("New title"))
if err != nil {
panic(err)
}
updated, err := change.Apply(source)
if err != nil {
panic(err)
}
fmt.Print(string(updated))
}
Output: ## New title ## Body.
func (*Document) PrepareReplaceAutoLink ¶
PrepareReplaceAutoLink prepares a source-preserving replacement of a promoted GFM autolink token.
func (*Document) PrepareReplaceCodeSpan ¶
PrepareReplaceCodeSpan prepares a source-preserving replacement of promoted code-span content.
func (*Document) PrepareReplaceEmphasis ¶
PrepareReplaceEmphasis prepares a source-preserving replacement of promoted emphasis content.
func (*Document) PrepareReplaceFencedCode ¶
PrepareReplaceFencedCode prepares a source-preserving replacement of promoted fenced-code content.
func (*Document) PrepareReplaceFrontMatterValue ¶
PrepareReplaceFrontMatterValue prepares a source-preserving replacement of a promoted simple front-matter scalar value.
func (*Document) PrepareReplaceHTMLAnchor ¶
PrepareReplaceHTMLAnchor prepares a source-preserving replacement of a promoted HTML anchor id/name value.
func (*Document) PrepareReplaceHTMLComment ¶
PrepareReplaceHTMLComment prepares a source-preserving replacement of a promoted HTML comment payload.
func (*Document) PrepareReplaceImageDestination ¶
PrepareReplaceImageDestination prepares a source-preserving replacement of a promoted image destination.
func (*Document) PrepareReplaceInlineLinkDestination ¶
func (d *Document) PrepareReplaceInlineLinkDestination(id NodeID, replacement []byte) (ChangeSet, error)
PrepareReplaceInlineLinkDestination prepares a source-preserving replacement of a promoted inline-link destination.
func (*Document) PrepareReplaceListItem ¶
PrepareReplaceListItem prepares a source-preserving replacement of promoted list-item content.
func (*Document) PrepareReplaceListItemSubtree ¶
PrepareReplaceListItemSubtree prepares replacement of one complete supported list-item subtree while preserving its external sibling shape and semantic parent.
func (*Document) PrepareReplaceParagraph ¶
PrepareReplaceParagraph prepares a source-preserving paragraph replacement.
func (*Document) PrepareReplaceReferenceDefinitionDestination ¶
func (d *Document) PrepareReplaceReferenceDefinitionDestination(id NodeID, replacement []byte) (ChangeSet, error)
PrepareReplaceReferenceDefinitionDestination prepares a source-preserving replacement of a promoted reference-definition destination.
func (*Document) PrepareReplaceSection ¶
PrepareReplaceSection prepares source-preserving replacement of one complete promoted section subtree.
func (*Document) PrepareReplaceSectionBody ¶
func (d *Document) PrepareReplaceSectionBody(headingID NodeID, replacement []byte) (ChangeSet, error)
PrepareReplaceSectionBody prepares source-preserving replacement of one promoted section's direct body.
func (*Document) PrepareReplaceStrikethrough ¶
PrepareReplaceStrikethrough prepares a source-preserving replacement of promoted strikethrough content.
func (*Document) PrepareReplaceStrong ¶
PrepareReplaceStrong prepares a source-preserving replacement of promoted strong-emphasis content.
func (*Document) PrepareReplaceTableCell ¶
PrepareReplaceTableCell prepares a source-preserving replacement of promoted table-cell content.
func (*Document) PrepareReplaceTableRow ¶
PrepareReplaceTableRow prepares source-preserving replacement of one complete promoted GFM table body row.
func (*Document) PrepareSetTableAlignments ¶
func (d *Document) PrepareSetTableAlignments(id NodeID, alignments []TableAlignment) (ChangeSet, error)
PrepareSetTableAlignments prepares one atomic source-preserving alignment update for every promoted GFM table column.
func (*Document) PrepareSetTableColumnAlignment ¶
func (d *Document) PrepareSetTableColumnAlignment(id NodeID, column int, alignment TableAlignment) (ChangeSet, error)
PrepareSetTableColumnAlignment prepares a source-preserving alignment change for one promoted GFM table column.
func (*Document) PrepareSetTaskChecked ¶
PrepareSetTaskChecked prepares a source-preserving GFM task state change.
func (*Document) ReferenceDefinition ¶
func (d *Document) ReferenceDefinition(id NodeID) (ReferenceDefinition, bool)
ReferenceDefinition returns typed detail for one promoted single-line reference definition.
func (*Document) SectionChildHeadingIDs ¶
SectionChildHeadingIDs returns one section's immediate child heading identities in source order.
func (*Document) SourceRange ¶
SourceRange returns a copy of one valid byte range from the immutable source snapshot. Caller mutations of the returned bytes do not affect the document.
func (*Document) Strikethrough ¶
func (d *Document) Strikethrough(id NodeID) (Strikethrough, bool)
Strikethrough returns typed detail for one promoted simple GFM strikethrough.
func (*Document) TableAlignments ¶
func (d *Document) TableAlignments(tableID NodeID) ([]TableAlignment, bool)
TableAlignments returns one semantic alignment per source-proven table column. The returned slice is caller-owned.
func (*Document) TableCell ¶
TableCell returns typed detail for one promoted non-empty GFM table cell.
func (*Document) TableHeaderCellIDs ¶
TableHeaderCellIDs returns the promoted non-empty header-cell identities owned by one promoted table in source order. Empty or otherwise unpromoted header cells are omitted.
func (*Document) TableRowAlignments ¶
func (d *Document) TableRowAlignments(rowID NodeID) ([]TableAlignment, bool)
TableRowAlignments returns the semantic column alignments for the table that owns one promoted body row. The returned slice has exactly TableRow.ColumnCount entries and is caller-owned.
func (*Document) TableRowCellIDs ¶
TableRowCellIDs returns the promoted non-empty cells owned by one promoted body row in source order. Empty cells are omitted because M5 does not assign them public cell identities.
func (*Document) TableRowHeaderCellIDs ¶
TableRowHeaderCellIDs returns the promoted non-empty header cells for the table that owns one promoted body row. Empty header cells are omitted because M5 does not assign them public cell identities.
func (*Document) TableRowIDs ¶
TableRowIDs returns the promoted body-row identities owned by one promoted table in source order. The returned slice is caller-owned and can be empty even when BodyRowCount is non-zero.
func (*Document) ThematicBreak ¶
func (d *Document) ThematicBreak(id NodeID) (ThematicBreak, bool)
ThematicBreak returns typed detail for one promoted top-level thematic break.
type DocumentBuilder ¶
type DocumentBuilder struct {
// contains filtered or unexported fields
}
DocumentBuilder constructs a new GFM document independently from parsed source snapshots.
M44-M89 support one optional document-leading YAML/TOML front-matter envelope, top-level ATX headings, parser-proven paragraphs, thematic breaks, parser-proven single-paragraph and reviewed multi-block blockquotes, flat or homogeneous nested unordered/ordered lists and task lists, supported fenced code, simple reference definitions, canonical unaligned/aligned tables, and typed inline construction for semantic text plus conservative code/emphasis/strong, strikethrough, link, image, and angle-autolink content, including bounded reviewed structured inline nesting. Generated documents use LF line endings, one blank line between GFM blocks, one blank line between retained front matter and a non-empty body, and one final line ending.
Example ¶
package main
import (
"fmt"
"github.com/zoster81/marksplice"
)
func main() {
builder := marksplice.NewDocumentBuilder()
if err := builder.AppendHeadingContent(1, marksplice.TextInline("Marksplice")); err != nil {
panic(err)
}
if err := builder.AppendParagraphContent(marksplice.TextInline("Source preserving GFM")); err != nil {
panic(err)
}
source, err := builder.Markdown()
if err != nil {
panic(err)
}
fmt.Print(string(source))
}
Output: # Marksplice Source preserving GFM
func NewDocumentBuilder ¶
func NewDocumentBuilder() *DocumentBuilder
NewDocumentBuilder returns an empty new-document builder.
func (*DocumentBuilder) AppendBlockquote ¶
func (b *DocumentBuilder) AppendBlockquote(inlineGFM string) error
AppendBlockquote appends one top-level blockquote containing one paragraph.
M56 introduced the canonical single-line '> ' form. M81 extends the same API to non-empty LF-separated paragraph GFM and writes canonical '> ' on every physical line. The block is retained only when construction-only source and semantic proof reproduce exactly one top-level blockquote paragraph; broader existing-source blockquote promotion remains unchanged.
func (*DocumentBuilder) AppendBlockquoteBlocks ¶
func (b *DocumentBuilder) AppendBlockquoteBlocks(depth int, content *DocumentBuilder) error
AppendBlockquoteBlocks appends one blockquote container from an existing child builder.
depth must be between 1 and 64. content is treated as an immutable construction snapshot: its current reviewed body blocks are copied into the new container, while later changes to content do not affect this builder. M83-M86 accept every reviewed body-block construction family, including recursive blockquote children whose total structural depth remains at most 64. Front matter remains a document envelope and is never accepted as a blockquote child.
func (*DocumentBuilder) AppendBlockquoteContent ¶
func (b *DocumentBuilder) AppendBlockquoteContent(content ...Inline) error
AppendBlockquoteContent appends one simple top-level blockquote from typed inline content.
func (*DocumentBuilder) AppendFencedCode ¶
func (b *DocumentBuilder) AppendFencedCode(content, info string) error
AppendFencedCode appends one top-level fenced code block.
M49 introduced the canonical unindented backtick form; M53 extends content to non-empty LF-separated multiline text. The fence is at least three bytes and grows beyond every potentially closing backtick run in the body. info is an optional single-line raw GFM info string and must not contain backticks.
func (*DocumentBuilder) AppendHeading ¶
func (b *DocumentBuilder) AppendHeading(level int, inlineGFM string) error
AppendHeading appends one top-level ATX heading.
inlineGFM must be one non-empty physical line of valid UTF-8 GFM source. The generated source is accepted only when reparsing proves the requested heading level and exact content range.
func (*DocumentBuilder) AppendHeadingContent ¶
func (b *DocumentBuilder) AppendHeadingContent(level int, content ...Inline) error
AppendHeadingContent appends one top-level ATX heading from typed inline content.
func (*DocumentBuilder) AppendNestedBlockquote ¶
func (b *DocumentBuilder) AppendNestedBlockquote(depth int, inlineGFM string) error
AppendNestedBlockquote appends one explicitly nested blockquote containing one paragraph.
depth is structural container depth and must be between 2 and 64. The writer derives the canonical repeated "> " prefix on every physical line; caller content remains raw paragraph GFM and must not introduce container structure that changes the requested nesting hierarchy.
func (*DocumentBuilder) AppendNestedBlockquoteContent ¶
func (b *DocumentBuilder) AppendNestedBlockquoteContent(depth int, content ...Inline) error
AppendNestedBlockquoteContent appends one explicitly nested blockquote from typed inline content.
func (*DocumentBuilder) AppendNestedOrderedList ¶
func (b *DocumentBuilder) AppendNestedOrderedList(items ...ListItemInput) error
AppendNestedOrderedList appends one homogeneous nested ordered list.
M58 uses the same structural depth contract as M57. Decimal numbering starts at 1 in every list container and indentation follows the actual generated parent marker width, including transitions such as '9.' to '10.'.
func (*DocumentBuilder) AppendNestedOrderedTaskList ¶
func (b *DocumentBuilder) AppendNestedOrderedTaskList(items ...TaskListItemInput) error
AppendNestedOrderedTaskList appends one homogeneous nested ordered GFM task list. M60 combines M58 container-local numbering/indentation with M48 task proof.
func (*DocumentBuilder) AppendNestedUnorderedList ¶
func (b *DocumentBuilder) AppendNestedUnorderedList(items ...ListItemInput) error
AppendNestedUnorderedList appends one homogeneous nested unordered list.
M57 accepts source-ordered ListItemInput values whose Depth describes the parent/child hierarchy. The writer uses canonical '-' markers and derives each nested indentation from the generated parent's exact content column.
func (*DocumentBuilder) AppendNestedUnorderedTaskList ¶
func (b *DocumentBuilder) AppendNestedUnorderedTaskList(items ...TaskListItemInput) error
AppendNestedUnorderedTaskList appends one homogeneous nested unordered GFM task list. M59 combines M57 structural depth with the exact M47 task-marker/state proof.
func (*DocumentBuilder) AppendOrderedList ¶
func (b *DocumentBuilder) AppendOrderedList(items ...string) error
AppendOrderedList appends one flat top-level ordered list.
M46 writes canonical sequential decimal markers beginning at 1 with '.' as the delimiter. The generated items must reparse as one ordered list container.
func (*DocumentBuilder) AppendOrderedTaskList ¶
func (b *DocumentBuilder) AppendOrderedTaskList(items ...TaskListItem) error
AppendOrderedTaskList appends one flat top-level ordered GFM task list.
M48 combines canonical sequential '1.', '2.', ... list markers with the same semantic task proof used by unordered task lists.
func (*DocumentBuilder) AppendParagraph ¶
func (b *DocumentBuilder) AppendParagraph(inlineGFM string) error
AppendParagraph appends one top-level paragraph.
M54 accepts non-empty valid UTF-8 GFM source with canonical LF line endings. The complete input must reparse as exactly one top-level paragraph; input that becomes multiple blocks or another block kind fails closed instead of being escaped or normalized implicitly.
func (*DocumentBuilder) AppendParagraphContent ¶
func (b *DocumentBuilder) AppendParagraphContent(content ...Inline) error
AppendParagraphContent appends one top-level single-line paragraph from typed inline content.
func (*DocumentBuilder) AppendReferenceDefinition ¶
func (b *DocumentBuilder) AppendReferenceDefinition(label, destination string) error
AppendReferenceDefinition appends one top-level single-line link reference definition.
M50 writes canonical angle-bracket destination syntax without a title. The generated definition is retained only when reparsing reproduces the exact label, destination, and source mapping.
func (*DocumentBuilder) AppendReferenceDefinitionWithTitle ¶
func (b *DocumentBuilder) AppendReferenceDefinitionWithTitle(label, destination, title string) error
AppendReferenceDefinitionWithTitle appends one top-level single-line link reference definition with a canonical double-quoted title.
M61 keeps the existing M50 angle-bracket destination form and accepts the block only when reparsing reproduces the exact label, destination, title, and source mapping. title must not require escaping in the canonical form.
func (*DocumentBuilder) AppendTable ¶
func (b *DocumentBuilder) AppendTable(header []string, rows ...[]string) error
AppendTable appends one top-level unaligned GFM table.
M51 requires at least one header column and one body row. Every body row must have the same width as header. Cell strings are caller-provided single-line GFM source; empty cells are allowed. The builder writes canonical outer pipes and '---' delimiter cells and retains the table only after exact body-row and semantic table-container proof.
func (*DocumentBuilder) AppendTableWithAlignments ¶
func (b *DocumentBuilder) AppendTableWithAlignments(header []string, alignments []TableAlignment, rows ...[]string) error
AppendTableWithAlignments appends one top-level GFM table with explicit semantic column alignments.
M62 preserves the M51 canonical outer-pipe/padding policy while writing delimiter cells as '---', ':---', '---:', or ':---:' for default, left, right, or center alignment. alignments must have exactly one entry per header column.
func (*DocumentBuilder) AppendThematicBreak ¶
func (b *DocumentBuilder) AppendThematicBreak() error
AppendThematicBreak appends one canonical top-level thematic break.
M55 writes exactly three hyphens and retains the block only when the internal GFM parser observes one top-level thematic break over those exact bytes.
func (*DocumentBuilder) AppendUnorderedList ¶
func (b *DocumentBuilder) AppendUnorderedList(items ...string) error
AppendUnorderedList appends one flat top-level unordered list.
Each item must be one non-empty physical line of valid UTF-8 inline GFM. M45 writes the canonical '-' marker and accepts the block only when reparsing proves that every generated item belongs to the one requested list container.
func (*DocumentBuilder) AppendUnorderedTaskList ¶
func (b *DocumentBuilder) AppendUnorderedTaskList(items ...TaskListItem) error
AppendUnorderedTaskList appends one flat top-level unordered GFM task list.
M47 writes canonical '-' list markers and '[ ]'/'[x]' task markers. The block is retained only when reparsing proves both the requested list container and each requested semantic task marker/state.
func (*DocumentBuilder) Markdown ¶
func (b *DocumentBuilder) Markdown() ([]byte, error)
Markdown returns newly generated canonical GFM source.
The returned bytes are caller-owned. The zero-value builder produces an empty document. A nil builder reports ErrInvalidConstruction.
func (*DocumentBuilder) SetTOMLFrontMatter ¶
func (b *DocumentBuilder) SetTOMLFrontMatter(fields ...FrontMatterFieldInput) error
SetTOMLFrontMatter configures one canonical leading TOML front-matter envelope. A DocumentBuilder can own at most one front-matter envelope.
func (*DocumentBuilder) SetYAMLFrontMatter ¶
func (b *DocumentBuilder) SetYAMLFrontMatter(fields ...FrontMatterFieldInput) error
SetYAMLFrontMatter configures one canonical leading YAML front-matter envelope. A DocumentBuilder can own at most one front-matter envelope.
type Emphasis ¶
type Emphasis struct {
// contains filtered or unexported fields
}
Emphasis is immutable typed detail for one promoted simple emphasis span.
type FencedCode ¶
type FencedCode struct {
// contains filtered or unexported fields
}
FencedCode is immutable typed detail for one promoted supported fenced code block.
func (FencedCode) ID ¶
func (f FencedCode) ID() NodeID
ID returns the fenced code block's snapshot-scoped node identity.
func (FencedCode) Range ¶
func (f FencedCode) Range() Range
Range returns the exact fenced-code content span replaced by PrepareReplaceFencedCode. Internal body line endings are part of this span. Fence lines, info-string source, and the final line ending immediately before the closing fence are outside it.
type FrontMatterField ¶
type FrontMatterField struct {
// contains filtered or unexported fields
}
FrontMatterField is immutable typed detail for one promoted simple leading YAML/TOML scalar field.
func (FrontMatterField) Format ¶
func (f FrontMatterField) Format() FrontMatterFormat
Format returns whether the field belongs to a YAML or TOML front-matter envelope.
func (FrontMatterField) ID ¶
func (f FrontMatterField) ID() NodeID
ID returns the field's snapshot-scoped node identity.
func (FrontMatterField) Key ¶
func (f FrontMatterField) Key() string
Key returns the recognized simple scalar field key.
func (FrontMatterField) Range ¶
func (f FrontMatterField) Range() Range
Range returns the exact scalar value span replaced by PrepareReplaceFrontMatterValue. Delimiters, key spelling, separator spacing, quote wrappers, comments, and line endings are outside this range.
type FrontMatterFieldInput ¶
FrontMatterFieldInput is construction-only input for one canonical simple YAML/TOML string scalar.
Key uses the existing conservative front-matter key alphabet. Value is written as one double-quoted string and therefore must not require escaping.
type FrontMatterFormat ¶
type FrontMatterFormat uint8
FrontMatterFormat identifies the source envelope format of a promoted front-matter field.
const ( FrontMatterFormatUnknown FrontMatterFormat = iota FrontMatterFormatYAML FrontMatterFormatTOML )
type HTMLAnchor ¶
type HTMLAnchor struct {
// contains filtered or unexported fields
}
HTMLAnchor is immutable typed detail for one promoted simple quoted id/name attribute on an <a> tag.
func (HTMLAnchor) Attribute ¶
func (a HTMLAnchor) Attribute() HTMLAnchorAttribute
Attribute returns whether the promoted anchor targets an id or name attribute.
func (HTMLAnchor) ID ¶
func (a HTMLAnchor) ID() NodeID
ID returns the HTML anchor's snapshot-scoped node identity.
func (HTMLAnchor) Range ¶
func (a HTMLAnchor) Range() Range
Range returns the exact quoted attribute value span replaced by PrepareReplaceHTMLAnchor. Tag/attribute spelling, spacing, quote wrappers, and other attributes are outside this range.
type HTMLAnchorAttribute ¶
type HTMLAnchorAttribute uint8
HTMLAnchorAttribute identifies the semantic anchor attribute targeted by an HTMLAnchor.
const ( HTMLAnchorAttributeUnknown HTMLAnchorAttribute = iota HTMLAnchorAttributeID HTMLAnchorAttributeName )
type HTMLComment ¶
type HTMLComment struct {
// contains filtered or unexported fields
}
HTMLComment is immutable typed detail for one promoted single-line HTML comment payload.
func (HTMLComment) ID ¶
func (c HTMLComment) ID() NodeID
ID returns the HTML comment's snapshot-scoped node identity.
func (HTMLComment) Range ¶
func (c HTMLComment) Range() Range
Range returns the exact comment payload span replaced by PrepareReplaceHTMLComment. Comment delimiters and preserved inner horizontal padding are outside this range.
type Heading ¶
type Heading struct {
// contains filtered or unexported fields
}
Heading is immutable typed detail for one promoted top-level heading.
func (Heading) Range ¶
Range returns the exact heading-content byte span replaced by PrepareRenameHeading. ATX markers, optional closing markers, Setext underlines, and line endings are outside this range.
func (Heading) Style ¶
func (h Heading) Style() HeadingStyle
Style returns whether the heading uses ATX or Setext source syntax.
type HeadingStyle ¶
type HeadingStyle uint8
HeadingStyle identifies the source syntax of a promoted heading.
const ( HeadingStyleUnknown HeadingStyle = iota HeadingStyleATX HeadingStyleSetext )
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
Image is immutable typed detail for one promoted simple inline image.
type Inline ¶
type Inline struct {
// contains filtered or unexported fields
}
Inline is a construction-only typed inline value.
Its zero value is invalid. Use the exported Inline construction functions rather than depending on its private representation.
func AutoLinkInline ¶
AutoLinkInline returns one canonical angle-autolink construction value. Validation succeeds only when reparsing produces the existing source-proven AutoLink capability.
func CodeInline ¶
CodeInline returns one conservative single-line code span construction value.
M76 selects an adaptive backtick delimiter longer than every internal run. Leading/trailing horizontal space and leading/trailing backticks are rejected because supporting those shapes would require semantic whitespace or delimiter normalization beyond the existing source-proven parsed CodeSpan capability.
func EmphasisInline ¶
EmphasisInline returns one conservative emphasis construction value. M88 permits bounded nesting of code, emphasis, strong, and strikethrough children while keeping links/images/autolinks outside this wrapper slice.
func ImageInline ¶
ImageInline returns one conservative inline-image construction value.
M77 writes the destination in angle brackets and accepts only TextInline alt-text children. M87 adds the separate WithTitle constructor; broader structured alt text remains deferred.
func ImageInlineWithTitle ¶
ImageInlineWithTitle returns one conservative inline-image construction value with a canonical double-quoted title. M87 applies the same conservative title policy as LinkInlineWithTitle.
func LinkInline ¶
LinkInline returns one conservative inline-link construction value.
M77 writes the destination in angle brackets and accepts only TextInline label children. M87 adds the separate WithTitle constructor; broader structured labels remain deferred.
func LinkInlineWithTitle ¶
LinkInlineWithTitle returns one conservative inline-link construction value with a canonical double-quoted title. M87 requires a non-empty title that needs no GFM escape or entity interpretation.
func ReferenceImageInline ¶
ReferenceImageInline returns one conservative full reference-image construction value. It follows the same existing exact-definition requirement as ReferenceLinkInline.
func ReferenceLinkInline ¶
ReferenceLinkInline returns one conservative full reference-link construction value. The exact reference label must identify one already-appended top-level reference definition in the destination DocumentBuilder when the value is appended.
func StrikethroughInline ¶
StrikethroughInline returns one conservative GFM strikethrough construction value. M88 permits bounded code/emphasis/strong children but rejects direct strikethrough-in-strikethrough nesting because adjacent tilde runs are ambiguous.
func StrongInline ¶
StrongInline returns one conservative strong-emphasis construction value. M88 applies the same bounded structured-child policy as EmphasisInline.
func TextInline ¶
TextInline returns semantic plain text for typed inline construction.
M75 encodes ASCII punctuation with canonical GFM backslash escapes so caller text cannot become Markdown syntax implicitly. Validation occurs when the value is appended to a DocumentBuilder.
type InlineLink ¶
type InlineLink struct {
// contains filtered or unexported fields
}
InlineLink is immutable typed detail for one promoted simple inline link.
func (InlineLink) ID ¶
func (l InlineLink) ID() NodeID
ID returns the inline link's snapshot-scoped node identity.
func (InlineLink) Range ¶
func (l InlineLink) Range() Range
Range returns the exact destination span replaced by PrepareReplaceInlineLinkDestination. Label, parentheses, destination wrappers, title syntax, and surrounding source are outside this range.
type Kind ¶
type Kind uint8
Kind identifies a structural Markdown node category.
const ( KindUnknown Kind = iota KindParagraph KindHeading KindListItem KindTask KindTableCell KindFencedCode KindStrikethrough KindCodeSpan KindEmphasis KindStrong KindInlineLink KindReferenceDefinition KindAutoLink KindFrontMatterField KindHTMLComment KindHTMLAnchor KindImage KindTableRow KindTable KindThematicBreak KindBlockquote )
type ListItem ¶
type ListItem struct {
// contains filtered or unexported fields
}
ListItem is immutable typed detail for one promoted single-line list item.
func (ListItem) ChildIDs ¶
ChildIDs returns the immediate supported list-item child identities in source order. Semantic children outside the promoted public subset are omitted.
func (ListItem) HasChildren ¶
HasChildren reports whether the supported single-line item owns one or more semantic direct child list items. It can be true even when ChildIDs is empty because unsupported children are not assigned public identities.
func (ListItem) Marker ¶
Marker returns the source marker/delimiter byte. Unordered items use '-', '*', or '+'; ordered items use '.' or ')'.
func (ListItem) ParentID ¶
ParentID returns the immediate supported list-item parent's snapshot-scoped identity. The boolean is false for root items and when the semantic parent exists but is not publicly promoted.
func (ListItem) Range ¶
Range returns the exact list-item content span replaced by PrepareReplaceListItem. Indentation, list numbering, marker/delimiter bytes, post-marker spacing, and line endings are outside this range.
func (ListItem) SubtreeRange ¶
SubtreeRange returns the exact complete supported subtree source span used by structural list-item operations. The boolean is false when Marksplice cannot prove that every semantic descendant belongs to the supported list-item model.
type ListItemInput ¶
ListItemInput is construction-only structured input for one item in a nested list.
Depth is structural depth, not source indentation: zero denotes a top-level item and each child is exactly one level deeper than its parent. DocumentBuilder derives canonical indentation from the generated parent marker width.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is an immutable public summary of one promoted structural node.
Syntax-specific details and source ranges are intentionally not part of this common value until their public semantics are reviewed.
type NodeID ¶
type NodeID struct {
// contains filtered or unexported fields
}
NodeID identifies a node within one parsed source snapshot.
Node IDs are deterministic for a snapshot, but they are not durable identities across arbitrary source changes or reparses. The representation is opaque; String is for diagnostics and does not define a persistence or round-trip format.
type Paragraph ¶
type Paragraph struct {
// contains filtered or unexported fields
}
Paragraph is immutable typed detail for one promoted top-level paragraph.
type Range ¶
Range is a half-open byte range [Start, End) in a source snapshot. The accessor returning a Range defines the semantic meaning of that span.
type ReferenceDefinition ¶
type ReferenceDefinition struct {
// contains filtered or unexported fields
}
ReferenceDefinition is immutable typed detail for one promoted single-line reference definition.
func (ReferenceDefinition) ID ¶
func (r ReferenceDefinition) ID() NodeID
ID returns the reference definition's snapshot-scoped node identity.
func (ReferenceDefinition) Range ¶
func (r ReferenceDefinition) Range() Range
Range returns the exact destination span replaced by PrepareReplaceReferenceDefinitionDestination. Label, colon, destination wrappers, title syntax, indentation, trailing spaces, and line endings are outside this range.
type Section ¶
type Section struct {
// contains filtered or unexported fields
}
Section is an immutable source-bound view governed by one promoted document heading.
func (Section) BodyRange ¶
BodyRange returns the direct body source span after the heading line and before the next heading of any level. Nested subsection headings and their content are outside this range.
func (Section) HeadingID ¶
HeadingID returns the snapshot-scoped heading node identity governing this section.
func (Section) ParentHeadingID ¶
ParentHeadingID returns the governing heading ID of the nearest enclosing section.
type Strikethrough ¶
type Strikethrough struct {
// contains filtered or unexported fields
}
Strikethrough is immutable typed detail for one promoted simple GFM strikethrough.
func (Strikethrough) ID ¶
func (s Strikethrough) ID() NodeID
ID returns the strikethrough's snapshot-scoped node identity.
func (Strikethrough) Range ¶
func (s Strikethrough) Range() Range
Range returns the exact strikethrough content span replaced by PrepareReplaceStrikethrough.
type Strong ¶
type Strong struct {
// contains filtered or unexported fields
}
Strong is immutable typed detail for one promoted simple strong-emphasis span.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is immutable typed detail for one promoted GFM table.
func (Table) BodyRowCount ¶
BodyRowCount returns the semantic number of body rows, including rows outside the promoted public row subset.
func (Table) ColumnCount ¶
ColumnCount returns the semantic/source-proven number of table columns.
type TableAlignment ¶
type TableAlignment uint8
TableAlignment identifies the semantic alignment of a GFM table column. It is used for new-document construction and read-only parsed table alignment access.
const ( TableAlignmentDefault TableAlignment = iota TableAlignmentLeft TableAlignmentRight TableAlignmentCenter )
type TableCell ¶
type TableCell struct {
// contains filtered or unexported fields
}
TableCell is immutable typed detail for one promoted non-empty GFM table cell.
func (TableCell) Range ¶
Range returns the exact table-cell content span replaced by PrepareReplaceTableCell. Pipes, cell padding, alignment syntax, neighboring cells, and line endings are outside this range.
type TableRow ¶
type TableRow struct {
// contains filtered or unexported fields
}
TableRow is immutable typed detail for one promoted GFM table body row.
func (TableRow) ColumnCount ¶
ColumnCount returns the semantic/source-proven number of columns in the body row.
func (TableRow) NextID ¶
NextID returns the nearest promoted body row after this row in the same table.
func (TableRow) PreviousID ¶
PreviousID returns the nearest promoted body row before this row in the same table.
type Task ¶
type Task struct {
// contains filtered or unexported fields
}
Task is immutable typed detail for one promoted GFM task marker.
type TaskListItem ¶
TaskListItem is structured input for one newly constructed GFM task-list item. InlineGFM is caller-provided inline GFM source; Checked selects the canonical '[x]' or '[ ]' task marker written before that content.
type TaskListItemInput ¶
TaskListItemInput is construction-only structured input for one item in a nested task list. Depth follows the same structural contract as ListItemInput.
type ThematicBreak ¶
type ThematicBreak struct {
// contains filtered or unexported fields
}
ThematicBreak is immutable typed detail for one promoted top-level thematic break.
func (ThematicBreak) ID ¶
func (t ThematicBreak) ID() NodeID
ID returns the thematic break's snapshot-scoped node identity.
func (ThematicBreak) Range ¶
func (t ThematicBreak) Range() Range
Range returns the exact complete physical line owned by structural thematic-break operations. When present, the line terminator is included.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
publictest
Package publictest hosts black-box tests of the public Marksplice API.
|
Package publictest hosts black-box tests of the public Marksplice API. |