ast

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: BSD-3-Clause Imports: 6 Imported by: 3

README

AST

The project provides the Avocet Tools implementation of a reStructuredText abstract syntax tree. It is used to specify the structs returned by both linear and inlinear RST parsers

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrettyB added in v0.1.1

func PrettyB(t BType) string

func PrettyE

func PrettyE(t EType) string

func PrettyP added in v0.1.2

func PrettyP(t PType) string

Types

type BType added in v0.1.1

type BType int
const (
	UnsetBType BType = iota
	Para
	Directive
	UList
	UListItem
	OList
	OListItem
	DList
	DListItem

	Footnote
	Endnote
	Citation
)

type Block added in v0.1.1

type Block struct {
	Type    BType    `json:"block_type"`
	Content *Content `json:"block_content"`

	Idrefs []string `json:"identity_references,omitempty"`
	Class  []string `json:"classifiers,omitempty"`

	File string `json:"filename"`
	Line int    `json:"line"`
}

func NewBlock added in v0.1.1

func NewBlock(t BType, fname string, line int) *Block

func (*Block) Has added in v0.1.1

func (blk *Block) Has(idref string) bool

func (*Block) HasClass added in v0.1.1

func (blk *Block) HasClass(cls string) bool

type Content added in v0.1.1

type Content struct {
	Inline   []*Element          `json:"inline_elements,omitempty" bson:"inline_elements,omitempty"`
	Meta     map[string]string   `json:"metadata_user,omitempty" bson:metadata_user,omitempty"`
	Internal map[string]string   `json:"metadata_internal,omitempty" bson:"metadata_internal,omitempty"`
	Data     []*Block            `json:"data,omitempty" bson:"data,omitempty"`
	Targets  map[string]*Content `json:"targets,omitempty" bson:"targets,omitempty"`
	Sections []*Section          `json:"sections" bson:"sections,omitempty"`
}

func NewContent added in v0.1.1

func NewContent() *Content

func (*Content) Add added in v0.1.1

func (con *Content) Add(blk *Block)

func (*Content) Append added in v0.1.1

func (con *Content) Append(blk *Block)

func (*Content) Insert added in v0.1.1

func (con *Content) Insert(e *Element)

func (*Content) Int added in v0.1.1

func (con *Content) Int(key, val string)

func (*Content) Merge added in v0.1.1

func (con *Content) Merge(ncon *Content)

func (*Content) Sect added in v0.1.1

func (con *Content) Sect(sect *Section)

func (*Content) Set added in v0.1.1

func (con *Content) Set(key, val string)

func (*Content) Target added in v0.1.1

func (con *Content) Target(key string, data *Content)

type Document added in v0.1.2

type Document struct {
	Valid bool `json:"-"`

	Path *Path `json:"path"`

	Content *Content `json:"content"`
}

func NewDocument added in v0.1.2

func NewDocument(p *Path) *Document

type EType

type EType int
const (
	Unset EType = iota
	Text
	Strong
	Emphasis
	Code
	Literal
	ULink
	VLink
	Foot
	End
	UCite
	VCite
	Replace
	Sub
	ULinkSub
	VLinkSub
	Role
)

type Element

type Element struct {
	Type EType  `json:"element_type" bson:"element_type"`
	Text string `json:"text" bson:"text"`

	File string `json:"file" bson:"file"`
	Line int    `json:"line" bson:"line"`
	Pos  int    `json:"position" bson:"position"`

	Dom  string `json:"domain,omitempty" bson:"domain,omitempty"`
	Role string `json:"role,omitempty" bson:"role,omitempty"`
	Key  string `json:"key,omitempty" bson:"key,omitempty"`
}

func NewElement

func NewElement(t EType, line, pos int) *Element

type PType added in v0.1.2

type PType int
const (
	UnsetPath PType = iota
	RST
	Tex
	Md
	PDF
	HTML
)

type Path added in v0.1.2

type Path struct {
	Type PType  `json:"type"`
	Ext  string `json:"extension"`

	Name     string    `json:"name_base"`
	Filename string    `json:"name_file"`
	Dir      string    `json:"path_dir"`
	Abs      string    `json:"path_absolute"`
	Rel      string    `json:"path_relative"`
	Size     int64     `json:"size"`
	Mtime    time.Time `json:"mtime"`
}

func NewPath added in v0.1.2

func NewPath(abs, rel string) *Path

func (*Path) Set added in v0.1.2

func (p *Path) Set()

type Section added in v0.1.1

type Section struct {
	Content *Content `json:"section_content"`

	Idrefs []string `json:"identity_references"`

	LiteralLevel string `json:"level_literal"`
	LocalLevel   int    `json:"level_local"`
	GlobalLevel  int    `json:"level_global"`
}

func NewSection added in v0.1.1

func NewSection(char string) *Section

func (*Section) Has added in v0.1.1

func (sec *Section) Has(idref string) bool

Jump to

Keyboard shortcuts

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