parser

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2025 License: Apache-2.0 Imports: 1 Imported by: 1

README

md-parser

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDigit

func IsDigit(ch byte) bool

IsDigit 判断是否为数字

Types

type Lexer

type Lexer struct {
	// contains filtered or unexported fields
}

Lexer 词法分析器

func NewLexer

func NewLexer(input string) *Lexer

NewLexer 创建一个新的词法分析器

func (*Lexer) NextToken

func (l *Lexer) NextToken() Token

NextToken 读取下一个标记

type Node

type Node struct {
	Type     TokenType
	Content  string
	Level    int
	Indent   int
	Link     string
	Alt      string
	Children []*Node
}

Node 表示AST中的一个节点

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser 语法分析器

func NewParser

func NewParser(lexer *Lexer) *Parser

NewParser 创建一个新的语法分析器

func (*Parser) Parse

func (p *Parser) Parse() *Node

Parse 解析Markdown文档

type Renderer

type Renderer struct{}

Renderer HTML渲染器

type Token

type Token struct {
	Type    TokenType
	Content string
	Level   int    // 用于标题和列表
	Indent  int    // 用于列表项缩进
	Link    string // 用于链接和图片
	Alt     string // 用于图片
}

Token 表示一个Markdown标记

type TokenType

type TokenType int

TokenType 表示标记类型

const (
	TokenEOF TokenType = iota
	TokenHeader
	TokenParagraph
	TokenList
	TokenListItem
	TokenCodeBlock
	TokenHorizontalRule
	TokenEmphasis
	TokenStrong
	TokenLink
	TokenImage
	TokenTable
	TokenTableRow
	TokenTableCell
	TokenText
)

Jump to

Keyboard shortcuts

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