document

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildLineMap

func BuildLineMap(text string) []int

func Parse

func Parse(source string) ([]Element, *BlockFeatures, *YAMLMetadata)

Types

type Admonition

type Admonition struct {
	Type  string
	Range Range
}

type BlockAttribute

type BlockAttribute struct {
	Attr ParsedAttribute
	Line int
}

func ScanBlockAttributes

func ScanBlockAttributes(source string) []BlockAttribute

type BlockFeatures

type BlockFeatures struct {
	HasOrderedList    bool
	HasUnorderedList  bool
	HasTable          bool
	HasDefinitionList bool
	HasFootnoteRefs   bool
	HasFootnoteDefs   bool
	HasStrikethrough  bool
	HasAttributes     bool
	FootnoteRefLabels []FootnoteLabel
	FootnoteDefLabels []FootnoteLabel
	Admonitions       []Admonition
}

type DefType

type DefType int
const (
	DefDoc DefType = iota
	DefTitle
	DefHeading
	DefLinkDef
)

type DitaSchema

type DitaSchema int
const (
	SchemaTopic DitaSchema = iota
	SchemaConcept
	SchemaTask
	SchemaReference
	SchemaMap
	SchemaMditaTopic
	SchemaMditaCoreTopic
	SchemaMditaExtendedTopic
	SchemaUnknown
)

func DitaSchemaFromString

func DitaSchemaFromString(s string) DitaSchema

type DocKind

type DocKind int
const (
	Topic DocKind = iota
	Map
)

func (DocKind) String

func (k DocKind) String() string

type Document

type Document struct {
	URI         string
	Version     int
	Text        string
	Lines       []int
	Elements    []Element
	Symbols     []Symbol
	Index       *Index
	Meta        *YAMLMetadata
	Kind        DocKind
	InlineAttrs []InlineAttribute
	BlockAttrs  []BlockAttribute
	RelLinks    *RelatedLinksInfo
}

func New

func New(uri string, version int, text string) *Document

func (*Document) ApplyChange

func (d *Document) ApplyChange(version int, newText string) *Document

func (*Document) Defs

func (d *Document) Defs() []Symbol

func (*Document) DocID

func (d *Document) DocID(rootURI string) paths.DocID

func (*Document) ElementAt

func (d *Document) ElementAt(pos Position) Element

func (*Document) Refs

func (d *Document) Refs() []Symbol

type Element

type Element interface {
	Rng() Range
	// contains filtered or unexported methods
}

type FootnoteLabel

type FootnoteLabel struct {
	Label string
	Range Range
}

type Heading

type Heading struct {
	Level       int
	Text        string
	ID          string
	Slug        paths.Slug
	Range       Range
	Attributes  *ParsedAttribute
	TaskSection TaskSectionKind
	IsRelLinks  bool
}

func (*Heading) IsTitle

func (h *Heading) IsTitle() bool

func (*Heading) Rng

func (h *Heading) Rng() Range

type Index

type Index struct {
	Meta      *YAMLMetadata
	Features  *BlockFeatures
	ShortDesc string
	// contains filtered or unexported fields
}

func BuildIndex

func BuildIndex(elements []Element, bf *BlockFeatures, meta *YAMLMetadata) *Index
func (idx *Index) AllLinks() []Element

func (*Index) Headings

func (idx *Index) Headings() []*Heading

func (*Index) HeadingsBySlug

func (idx *Index) HeadingsBySlug(slug paths.Slug) []*Heading

func (*Index) LinkDefByLabel

func (idx *Index) LinkDefByLabel(label string) *LinkDef

func (*Index) LinkDefs

func (idx *Index) LinkDefs() []*LinkDef
func (idx *Index) MdLinks() []*MdLink

func (*Index) Title

func (idx *Index) Title() *Heading

type InlineAttribute

type InlineAttribute struct {
	Attr       ParsedAttribute
	TargetKind string // "bold", "italic", "code", "paragraph"
	TargetText string
	Line       int
	Col        int
}

func ScanInlineAttributes

func ScanInlineAttributes(source string) []InlineAttribute

type LinkDef

type LinkDef struct {
	Label string
	URL   string
	Range Range
}

func (*LinkDef) Rng

func (l *LinkDef) Rng() Range
type MdLink struct {
	Text   string
	URL    string
	Anchor string
	IsRef  bool
	Range  Range
}

func (*MdLink) Rng

func (m *MdLink) Rng() Range

type ParsedAttribute

type ParsedAttribute struct {
	Classes   []string
	ID        string
	KeyValues map[string]string
	Range     Range
}

func ParseAttrString

func ParseAttrString(s string) ParsedAttribute

type Position

type Position struct {
	Line      int `json:"line"`
	Character int `json:"character"`
}

type Range

type Range struct {
	Start Position `json:"start"`
	End   Position `json:"end"`
}

func Rng

func Rng(sl, sc, el, ec int) Range

type RefType

type RefType int
const (
	RefMdLink RefType = iota
	RefKeyref
)

type RelatedLinksInfo

type RelatedLinksInfo struct {
	HeadingLine int
	Links       []*MdLink
}

type SymKind

type SymKind int
const (
	DefKind SymKind = iota
	RefKind
)

func (SymKind) String

func (k SymKind) String() string

type Symbol

type Symbol struct {
	Kind    SymKind
	DefType DefType
	RefType RefType
	Name    string
	Slug    paths.Slug
	DocURI  string
	Range   Range
}

type TaskSectionKind

type TaskSectionKind int
const (
	TaskSectionNone TaskSectionKind = iota
	TaskSectionPrereq
	TaskSectionContext
	TaskSectionResult
	TaskSectionPostreq
	TaskSectionTroubleshooting
)

type YAMLMetadata

type YAMLMetadata struct {
	Author      string
	Source      string
	Publisher   string
	Permissions string
	Audience    string
	Category    string
	Keywords    []string
	ResourceID  string
	Schema      DitaSchema
	SchemaRaw   string
	OtherMeta   map[string]string
	Range       Range
}

Jump to

Keyboard shortcuts

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