internals

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LatchFlags = func(v *Bits) (
		func(f Bits), func(f Bits), func(f Bits), func(f Bits) bool) {
		return func(f Bits) { AddFlag(v, f) },
			func(f Bits) { RemoveFlag(v, f) },
			func(f Bits) { FlipFlag(v, f) },
			func(f Bits) bool { return HasFlag(v, f) }
	}

	AddFlag    = func(v *Bits, f Bits) { *v |= f }
	RemoveFlag = func(v *Bits, f Bits) { *v &^= f }
	FlipFlag   = func(v *Bits, f Bits) { *v ^= f }
	HasFlag    = func(v *Bits, f Bits) bool { return *v&f != 0 }
)
View Source
var (
	// LinkRegexp is the regexp for matching links
	LinkRegexp = regexp.MustCompile(`\[\[([^][]+)\]\[([^][]+)\]\]`)
	// URLRegexp is yoinked from https://ihateregex.io/expr/url/
	URLRegexp = regexp.MustCompile(`(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*))`)
	// BoldText is the regexp for matching bold text
	BoldText = markupRegex(`\*`)
	// ItalicText is the regexp for matching italic text
	ItalicText = markupRegex(`/`)
	// BoldItalicText is the regexp for matching bold-italic text from the left
	BoldItalicTextBegin = regexp.MustCompile(`(?mU)(^|[ ()_%<>])\*/`)
	// BoldItalicTextEnd is the regexp for matching bold-italic text from the right
	BoldItalicTextEnd = regexp.MustCompile(`(?mU)/\*($|[ (),.!?;&_%><])`)
	// VerbatimText is the regexp for matching verbatim text
	VerbatimText = markupRegex(`[~=]`)
	// StrikethroughText is the regexp for matching strikethrough text
	StrikethroughText = markupRegex(`\+`)
	// UnderlineText is the regexp for matching underline text
	UnderlineText = markupRegex(`_`)
	// KeyboardRegexp is the regexp for matching keyboard text
	KeyboardRegexp = regexp.MustCompile(`kbd:\[([^][]+)\]`)
	// MathRegexp is the regexp for matching math text
	MathRegexp = regexp.MustCompile(`(?mU)\$(.+)\$`)
	// ImageRegexp is the regexp for matching images (png, gif, jpg, jpeg, svg, webp)
	ImageExtRegexp = regexp.MustCompile(`\.(png|gif|jpg|jpeg|svg|webp)$`)
	// AudioRegexp is the regexp for matching audio (mp3, flac, midi)
	AudioFileExtRegexp = regexp.MustCompile(`\.(mp3|flac|midi)$`)
	// VideoFileExtRegexp matches commonly used video file formats
	VideoFileExtRegexp = regexp.MustCompile(`\.(mp4|mkv|mov|flv|webm)$`)

	// NewLineRegexp matches a new line for non-math environments
	NewLineRegexp = regexp.MustCompile(`(?m)([^\\])\\ `)

	// FootnoteRegexp is the regexp for matching footnotes
	FootnoteRegexp = regexp.MustCompile(`(?mU)\[fn:: (.+)\]([:;!?\t\n. ]|$)`)
	// FootnoteReferenceRegexp is the regexp for matching footnotes references
	FootnotePostProcessingRegexp = regexp.MustCompile(`!(\d+)!`)
)

Functions

func Max

func Max[T Number](a, b T) T

Max returns the maximum of two numbers

func Min

func Min[T Number](a, b T) T

Min returns the minimum of two numbers

Types

type Bits added in v1.2.2

type Bits uint16
const (
	InListFlag Bits = 1 << iota
	InTableFlag
	InTableHasHeadersFlag
	InSourceCodeFlag
	InRawHTMLFlag
	InQuoteFlag
	InCenterFlag
	InDetailsFlag
	InDropCapFlag
)

type Content

type Content struct {
	// Type is the type of content
	Type TypeContent

	// Options tells us about the options enabled on the type
	Options Bits
	// HeadingLevel is the heading level of the content (1 being the title, starts at 2)
	HeadingLevel int
	// HeadingChild tells us if the current heading is a child of some previous heading
	HeadingChild bool
	// HeadingFirst tells us if the current heading is the first heading on the page
	HeadingFirst bool
	// HeadingLast tells us if the current heading is the last heading on the page
	HeadingLast bool
	// Heading is the heading text
	Heading string
	// Paragraph is the paragraph text
	Paragraph string
	// List is the list of items, unordered
	List []string
	// ListNumbered is the list of items, numbered
	ListNumbered []string
	// Link is the link text
	Link string
	// LinkTitle is the link title
	LinkTitle string
	// SourceCode is the source code
	SourceCode string
	// SourceCodeLanguage is the language of the source code
	SourceCodeLang string
	// RawHTML is the raw HTML
	RawHTML string
	// AttentionTitle is the attention text title (IMPORTANT, WARNING, etc.)
	AttentionTitle string
	// AttentionText is the attention text
	AttentionText string
	// Table is the table of items
	Table [][]string
	// TableHeaders tell us whether the table has headers
	// (use the first row as headers instead of data)
	TableHeaders bool
	// Caption is the current caption
	Caption string
	// Summary is the current summary
	Summary string
}

Content is a piece of content of a page

func (Content) IsAttentionBlock

func (c Content) IsAttentionBlock() bool

IsAttentionBlock tells us if the content is an attention text block

func (Content) IsCentered

func (c Content) IsCentered() bool

func (Content) IsDetails added in v1.2.2

func (c Content) IsDetails() bool

func (Content) IsDropCap

func (c Content) IsDropCap() bool

func (Content) IsHeading

func (c Content) IsHeading() bool

IsHeading tells us if the content is a heading

func (Content) IsHorizontalLine

func (c Content) IsHorizontalLine() bool

IsHorizontalLine tells us if the content is a horizontal line

func (c Content) IsLink() bool

IsLink tells us if the content is a link

func (Content) IsList

func (c Content) IsList() bool

IsList tells us if the content is a list

func (Content) IsListNumbered

func (c Content) IsListNumbered() bool

IsListNumbered tells us if the content is a numbered list

func (Content) IsParagraph

func (c Content) IsParagraph() bool

IsParagraph tells us if the content is a paragraph

func (Content) IsQuote

func (c Content) IsQuote() bool

func (Content) IsRawHTML

func (c Content) IsRawHTML() bool

IsRawHTML tells us if the content is a raw HTML block

func (Content) IsSourceCode

func (c Content) IsSourceCode() bool

IsSourceCode tells us if the content is a source code block

func (Content) IsTable

func (c Content) IsTable() bool

IsTable tells us if the content block is a table

type Link struct {
	// Rel is the rel of the link tag
	Rel string
	// Type is the type of the link tag
	Type string
	// Href is the href of the link tag
	Href string
}

Link is a struct for holding the link tag

type MetaTag

type MetaTag struct {
	// Name is the name of the meta tag
	Name string
	// Content is the content of the meta tag
	Content string
	// Propery is the property of the meta tag
	Property string
}

MetaTag is a struct for holding the meta tag

type Number

type Number interface {
	int | float64
}

Number is a type for numbers

type Page

type Page struct {
	// Title is the title of the page
	Title string
	// Date is the date of the page
	Date string
	// DateHoloscene tells us whether the first paragraph
	// on the page is given as holoscene date stamp
	DateHoloscene bool
	// URL is the URL of the page
	URL string
	// Contents is the contents of the page
	Contents []Content
	// Footnotes is the footnotes of the page
	Footnotes []string
	// Scripts is the scripts of the page
	Scripts []string
	// Stylesheets is the list of css of the page
	Stylesheets []string
}

Page is a struct for holding the page contents

type TypeContent

type TypeContent uint8

TypeContent is the type of content, used for enums

const (
	// TypeHeading is the type of heading
	TypeHeading TypeContent = iota
	// TypeParagraph is the type of paragraph, which is just text
	TypeParagraph
	// TypeList is the type of unordered list
	TypeList
	// TypeListNumbered is the type of numbered list
	TypeListNumbered
	// TypeLink is the type of link
	TypeLink
	// TypeSourceCode is the type of source code block
	TypeSourceCode
	// TypeRawHTML is the type of raw HTML block
	TypeRawHTML
	// TypeHorizontalLine is the type of horizontal line
	TypeHorizontalLine
	// TypeAttentionText is the type of attention text block
	TypeAttentionText
	// TypeTable is the type of a table
	TypeTable
	// TypeDetails is the type for html details
	TypeDetails
)

Jump to

Keyboard shortcuts

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