Documentation ¶
Index ¶
- Variables
- func Max[T Number](a, b T) T
- func Min[T Number](a, b T) T
- type Bits
- type Content
- func (c Content) IsAttentionBlock() bool
- func (c Content) IsCentered() bool
- func (c Content) IsDetails() bool
- func (c Content) IsDropCap() bool
- func (c Content) IsHeading() bool
- func (c Content) IsHorizontalLine() bool
- func (c Content) IsLink() bool
- func (c Content) IsList() bool
- func (c Content) IsListNumbered() bool
- func (c Content) IsParagraph() bool
- func (c Content) IsQuote() bool
- func (c Content) IsRawHTML() bool
- func (c Content) IsSourceCode() bool
- func (c Content) IsTable() bool
- type Link
- type MetaTag
- type Number
- type Page
- type TypeContent
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 ¶
Types ¶
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 ¶
IsAttentionBlock tells us if the content is an attention text block
func (Content) IsCentered ¶
func (Content) IsHorizontalLine ¶
IsHorizontalLine tells us if the content is a horizontal line
func (Content) IsListNumbered ¶
IsListNumbered tells us if the content is a numbered list
func (Content) IsParagraph ¶
IsParagraph tells us if the content is a paragraph
func (Content) IsSourceCode ¶
IsSourceCode tells us if the content is a source code block
type Link ¶
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 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 )
Click to show internal directories.
Click to hide internal directories.