parse

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package parse provides parsing facilities for supertext files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseGeoLocation

func ParseGeoLocation(coords string) (float64, float64, bool)

Types

type Lexed

type Lexed []Token

func Lex

func Lex(text string) Lexed

func (Lexed) DocHeading

func (p Lexed) DocHeading() bool

func (Lexed) DocSummary

func (p Lexed) DocSummary(level uint8, maxlen int) string

func (Lexed) Lookup

func (p Lexed) Lookup(anchor string) (Lexed, bool)

func (Lexed) SubTree

func (p Lexed) SubTree() Lexed

func (Lexed) Values

func (p Lexed) Values(key string) Lexed

func (Lexed) Write

func (p Lexed) Write(w io.Writer) error

type Token

type Token struct {
	Typ       TokenType
	Line      int
	Offset    int // Counted in runes
	EndOffset int // Counted in runes

	Anchor string // HEADING, PREFORMATTED, LINK
	Key    string // POINT, HEADING

	DataType string // POINT

	// HEADING
	Title string
	Level uint8

	// PARAGRAPH, PREFORMATTED, QUOTE
	Body string

	// POINT, LINK
	Value string

	// PREFORMATTED
	Ext string
}

func (Token) Rest

func (n Token) Rest() string

func (Token) TocView

func (n Token) TocView() string

type TokenType

type TokenType int
const (
	PARAGRAPH TokenType = iota
	HEADING
	PREFORMATTED
	LINK
	POINT
	QUOTE
)

Jump to

Keyboard shortcuts

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