Documentation ¶
Overview ¶
Package token package contains all the data abound the tokens. It is divided in token.go, which contains single and general tokens, line.go, which contains the line tokens and paragraph.go, which contains the paragraph tokens
Index ¶
- Constants
- Variables
- func EscapeString(str string) string
- type AtToken
- type BoldToken
- type CheckBoxToken
- type CodeLine
- type CodeParagraph
- type DivisorLine
- type DivisorParagraph
- type EqualLine
- type EqualToken
- type EscapeToken
- type HeaderLine
- type HeaderParagraph
- type HeaderToken
- type ItalicToken
- type LessLine
- type LessToken
- type LineContainer
- type LineToken
- type ListLine
- type ListParagraph
- type NewLineToken
- type ParagraphToken
- type PipeToken
- type QuoteToken
- type SBracketCloseToken
- type SBracketOpenToken
- type SimpleToken
- type SubtitleParagraph
- type TabToken
- type TextParagraph
- type TextToken
- type TitleParagraph
- type Token
- type Type
Constants ¶
const ( //TypeUndefined is an undefined token TypeUndefined = iota //TypeBold is an bold starting/ending token TypeBold = '*' //TypeItalic is an italic starting/ending token TypeItalic = '/' //TypeNewLine is a newline TypeNewLine = '\n' //TypeTab is a tab TypeTab = '\t' //TypeHeader is the token used in an header TypeHeader = '+' //TypeLess is the token used for subtitle and for divisor TypeLess = '-' //TypeEqual is the token used for title TypeEqual = '=' TypeSBracketOpen = '[' TypeSBracketClose = ']' TypeEscape = '\\' //TypeText is a text token TypeText = -1 TypePipe = '|' TypeQuote = '"' TypeAt = '@' TypeParagraphHeader TypeParagraphText TypeParagraphDivisor TypeParagraphTitle TypeParagraphSubtitle TypeParagraphList TypeCheckBox )
Types definition They can rapresent the rapresented char but it is not mandatory
Variables ¶
var WhitespaceEscape = []Type{ TypeBold, TypeItalic, TypeTab, TypeLess, }
WhitespaceEscape is a slice of types that can be escaped from the EscapeToken
Functions ¶
func EscapeString ¶
EscapeString escapes the current string from charachetrs like * or /
Types ¶
type CheckBoxToken ¶
CheckBoxToken rapresent a checkbox, it is composed by [Char] (SBRacketOpenToken,TextToken,SBRacketCloseToken)
type CodeParagraph ¶
type CodeParagraph struct { ParagraphToken Lang string Text TextParagraph }
CodeParagraph is a paragraph containing code
type DivisorLine ¶
type DivisorLine struct {
LineToken
}
DivisorLine rapresent a header line
func (DivisorLine) String ¶
func (l DivisorLine) String() string
type DivisorParagraph ¶
type DivisorParagraph struct {
ParagraphToken
}
DivisorParagraph is a pragraph containing a divisor line
func (DivisorParagraph) Type ¶
func (p DivisorParagraph) Type() Type
Type returns the type of the Token
type EqualLine ¶
EqualLine rapresent a line containing only EqualToken EqualLine is used for Titles(Main and not)
type EscapeToken ¶
type EscapeToken struct{ SimpleToken }
EscapeToken is a special toekn used for escpaing other tokens, it rapresent a \ token
type HeaderLine ¶
HeaderLine rapresent a header line
func (HeaderLine) String ¶
func (l HeaderLine) String() string
type HeaderParagraph ¶
type HeaderParagraph struct { ParagraphToken sMark.Options }
HeaderParagraph is a pragraph containing header info
func (HeaderParagraph) Type ¶
func (p HeaderParagraph) Type() Type
Type returns the type of the Token
type LineContainer ¶
LineContainer is a token which rappresent a list of Tokens with some attributes
func LineContainerFromString ¶
func LineContainerFromString(txt string) LineContainer
LineContainerFromString generate a LineContainer from a given text, it parses the tab and add them.
func (LineContainer) String ¶
func (t LineContainer) String() string
String returns a string of the line with all tokens
func (LineContainer) StringNoTab ¶
func (t LineContainer) StringNoTab() string
StringNoTab returns a string of the line with all tokens without tab
type ListLine ¶
type ListLine struct { LineToken Text LineContainer Indentation int }
ListLine rapresent an element of a list
type ListParagraph ¶
type ListParagraph struct { ParagraphToken Items []ListLine }
ListParagraph is a paragraph rapresenting a List
type ParagraphToken ¶
type ParagraphToken interface { Token IsParagraph() }
ParagraphToken is a special interface that indicates a paragraph
type PipeToken ¶
type PipeToken struct{ SimpleToken }
PipeToken is a simple token, rapresenting a | token
type QuoteToken ¶
type QuoteToken struct{ SimpleToken }
QuoteToken is a simple token rapresenting a " token
type SBracketCloseToken ¶
type SBracketCloseToken struct{ SimpleToken }
SBracketCloseToken rapresent a ] token
func (SBracketCloseToken) Type ¶
func (p SBracketCloseToken) Type() Type
Type returns the type of the Token
type SBracketOpenToken ¶
type SBracketOpenToken struct{ SimpleToken }
SBracketOpenToken rapresent a [ token
func (SBracketOpenToken) Type ¶
func (p SBracketOpenToken) Type() Type
Type returns the type of the Token
type SimpleToken ¶
SimpleToken is a generic interface for implementing simple tokens, a token is a rune which is divided by normal text
type SubtitleParagraph ¶
type SubtitleParagraph struct { ParagraphToken Text string Indentation int }
SubtitleParagraph is a paragraph rapresenting a Subtitle, it is similar to TitleParagraph
func (SubtitleParagraph) Type ¶
func (p SubtitleParagraph) Type() Type
Type returns the type of the Token
type TextParagraph ¶
type TextParagraph struct { ParagraphToken Indentation int Lines []LineContainer }
TextParagraph rapresent a single paragraph
type TextToken ¶
type TextToken struct { Token Indentation int Text string //Attributes Bold bool Italic bool Strike bool Link string Image image.Image }
TextToken is a complex token which contains text and some attribute.
func (TextToken) String ¶
String creates a string with the content of the TextToken It respect attributes
func (TextToken) StringEscape ¶
StringEscape creates a string with the content of the TextToken It respect attributes, it escapes with backslash if it find escaped char
type TitleParagraph ¶
type TitleParagraph struct { ParagraphToken Text string Indentation int }
TitleParagraph is a paragraph rapresenting a Title