Documentation
¶
Index ¶
Constants ¶
View Source
const ( RawInlineFormatKey = "$RawInlineFormatKey" RawBlockFormatKey = "$RawBlockLevelKey" HeadingLevelKey = "$HeadingLevelKey" SparseListNodeKey = "$SparseListNodeKey" DefinitionListItemKey = "$DefinitionListItemKey" IdKey = "id" RoleKey = "role" LinkHrefKey = "href" ImgAltKey = "alt" ImgSrcKey = "src" TaskListClass = "task-list" CheckedTaskItemClass = "checked" UncheckedTaskItemClass = "unchecked" LeftAlignment = "left" CenterAlignment = "center" RightAlignment = "right" DefaultAlignment = "" )
Variables ¶
View Source
var ( UnorderedListByteMask = tokenizer.NewByteMask([]byte("-+*")) DigitByteMask = tokenizer.NewByteMask([]byte("0123456789")) LowerAlphaByteMask = tokenizer.NewByteMask([]byte("abcdefghijklmnopqrstuvwxyz")) UpperAlphaByteMask = tokenizer.NewByteMask([]byte("ABCDEFGHIJKLMNOPQRSTUVWXYZ")) )
Functions ¶
func CreateSectionId ¶
Types ¶
type Conversion ¶
type Conversion[T any] func(state ConversionState[T], next func(Children))
type ConversionContext ¶
ConversionContext holds registry of conversion functions for all AST nodes Note, that it has generic parameter T which is opaque for the library and caller can use it however he wants (for example, render data somewhere or just analyze AST and accumulate some knowledge in the internal fields of T)
Also, third-party libraries can implement custom factories for ConversionContext for targets different from HTML (see https://git.sr.ht/~ser/godjot/issues/14 for more details)
func NewConversionContext ¶
func NewConversionContext(_ backCompatGuard) ConversionContext[backCompatGuard]
NewConversionContext kept to simplify migration from old API to the new approach Deprecated: use djot_html.New(converters...) instead See https://git.sr.ht/~ser/godjot/releases/tag/v2.0.0
func (ConversionContext[T]) ConvertDjot ¶
func (context ConversionContext[T]) ConvertDjot( builder T, nodes ...TreeNode[DjotNode], ) T
type ConversionRegistry ¶
type ConversionRegistry[T any] map[DjotNode]Conversion[T]
type ConversionState ¶
type DjotContext ¶
type DjotContext struct {
References map[string][]byte
ReferenceAttributes map[string]tokenizer.Attributes
FootnoteId map[string]int
}
func BuildDjotContext ¶
func BuildDjotContext(document []byte, list tokenizer.TokenList[djot_tokenizer.DjotToken]) DjotContext
type DjotLocalContext ¶
type DjotLocalContext struct {
TextNode bool
TableNode bool
TableProps TableProps
}
type DjotNode ¶
type DjotNode int
const ( DocumentNode DjotNode = iota SectionNode ParagraphNode HeadingNode QuoteNode UnorderedListNode OrderedListNode DefinitionListNode TaskListNode ListItemNode DefinitionTermNode DefinitionItemNode CodeNode RawNode ThematicBreakNode DivNode TableNode TableCaptionNode TableRowNode TableHeaderNode TableCellNode ReferenceDefNode FootnoteDefNode TextNode EmphasisNode StrongNode HighlightedNode SubscriptNode SuperscriptNode InsertNode DeleteNode SymbolsNode VerbatimNode LineBreakNode LinkNode ImageNode SpanNode )
type QuoteDirection ¶
type QuoteDirection int
const ( OpenQuote QuoteDirection = +1 CloseQuote QuoteDirection = -1 )
type TableProps ¶
type TreeNode ¶
type TreeNode[T ~int] struct { Type T Attributes tokenizer.Attributes Children []TreeNode[T] Text []byte Index int }
func BuildDjotAst ¶
Click to show internal directories.
Click to hide internal directories.