Documentation
¶
Index ¶
- func SplitRichTextPer(segments []RichTextSegment, count int) [][]RichTextSegment
- func StripInlineFormatting(s string) string
- type Blockquote
- type Code
- type Component
- type ComponentType
- type H1
- type H2
- type H3
- type H4
- type H5
- type H6
- type HorizontalRule
- type Image
- type LinkInfo
- type List
- type ListItem
- type PlainText
- type Position
- type RichTextSegment
- type Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SplitRichTextPer ¶
func SplitRichTextPer(segments []RichTextSegment, count int) [][]RichTextSegment
SplitRichTextPer splits rich text segments into chunks where each chunk's total rune count does not exceed the given limit. Formatting is preserved across split boundaries by splitting individual segments as needed. It prefers splitting at word boundaries (spaces) similar to SplitPer.
func StripInlineFormatting ¶
StripInlineFormatting removes markdown inline formatting from text and decodes HTML entities.
Types ¶
type Blockquote ¶
Blockquote represents a Markdown blockquote (lines starting with >).
func (Blockquote) RowNum ¶
func (b Blockquote) RowNum() int
RowNum returns the number of Excel rows needed (lines + top/bottom padding).
func (Blockquote) Text ¶
func (b Blockquote) Text() string
Text returns all blockquote lines joined with newlines.
func (Blockquote) ToString ¶
func (b Blockquote) ToString() string
func (Blockquote) Type ¶
func (Blockquote) Type() ComponentType
type Code ¶
func (Code) Type ¶
func (Code) Type() ComponentType
type Component ¶
type Component interface {
ToString() string
Type() ComponentType
}
Component is the interface implemented by all parsed Markdown elements.
type ComponentType ¶
type ComponentType int
const ( TypeH1 ComponentType = iota TypeH2 TypeH3 TypeH4 TypeH5 TypeH6 TypePlainText TypeTable TypeImage TypeCode TypeList TypeHorizontalRule TypeBlockquote )
func (ComponentType) String ¶
func (t ComponentType) String() string
type H6 ¶
type H6 struct {
Text string
Chapter int
Section int
Term int
Item int
SubItem int
Detail int
Line int
}
func (H6) Type ¶
func (H6) Type() ComponentType
type HorizontalRule ¶
HorizontalRule represents a Markdown horizontal rule (---, ***, ___).
func (HorizontalRule) ToString ¶
func (h HorizontalRule) ToString() string
func (HorizontalRule) Type ¶
func (HorizontalRule) Type() ComponentType
type LinkInfo ¶
LinkInfo holds a parsed Markdown link's text and URL.
func ExtractLinks ¶
ExtractLinks returns all Markdown links and autolinks found in the string, sorted by their position in the source text.
type List ¶
List represents a bullet or numbered list.
func (List) Type ¶
func (List) Type() ComponentType
type ListItem ¶
type ListItem struct {
Text string
RichText []RichTextSegment
Ordered bool
Checked *bool
Number int // 1-based number for ordered lists
Indent int // nesting level (0-based)
}
ListItem represents a single item in a list.
type PlainText ¶
type PlainText struct {
Text string
Links []LinkInfo
RichText []RichTextSegment
Chapter int
Section int
Term int
Line int
}
func (PlainText) SplitPer ¶
SplitPer splits text into chunks of the given rune count. It prefers splitting at word boundaries (spaces) to avoid breaking words.
func (PlainText) Type ¶
func (PlainText) Type() ComponentType
type RichTextSegment ¶
RichTextSegment represents a segment of text with optional bold/italic/strikethrough/code formatting.
func ParseRichText ¶
func ParseRichText(s string) []RichTextSegment
ParseRichText parses inline bold/italic formatting and returns segments. Inline code regions (backtick-delimited) are protected from emphasis parsing.
type Table ¶
type Table struct {
Header []string
HeaderRichText [][]RichTextSegment
Data [][]string
DataRichText [][][]RichTextSegment
Alignments []string
Chapter int
Section int
Term int
Line int
}
func (Table) MaxColDataBytes ¶
MaxColDataBytes returns the max byte length of each column's data.
func (Table) Type ¶
func (Table) Type() ComponentType