parse

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToString added in v1.1.4

func ToString(pieces []Piece) string

Types

type Article

type Article struct {
	Title   Piece
	Meta    []string
	Tags    string
	Content []Piece
}

func ParseFromHTMLFile

func ParseFromHTMLFile(filepath string, imagePolicy ImagePolicy) Article

func ParseFromHTMLString

func ParseFromHTMLString(s string, imagePolicy ImagePolicy) Article

func ParseFromReader

func ParseFromReader(r io.Reader, imagePolicy ImagePolicy) Article

func ParseFromURL

func ParseFromURL(url string, imagePolicy ImagePolicy) Article

func (Article) ToString added in v1.1.4

func (article Article) ToString() string
type Header struct {
	Level int
	Text  string
}

type ImagePolicy

type ImagePolicy int32
const (
	IMAGE_POLICY_URL ImagePolicy = iota
	IMAGE_POLICY_SAVE
	IMAGE_POLICY_BASE64
)

func ImageArgValue2ImagePolicy

func ImageArgValue2ImagePolicy(val string) ImagePolicy

type Piece

type Piece struct {
	Type  PieceType
	Val   Value
	Attrs map[string]string
}

type PieceType

type PieceType int32
const (
	HEADER           PieceType = iota // 0  标题
	LINK                              // 1  链接
	NORMAL_TEXT                       // 2  文字
	BOLD_TEXT                         // 3  粗体文字
	ITALIC_TEXT                       // 4  斜体文字
	BOLD_ITALIC_TEXT                  // 5  粗斜体
	IMAGE                             // 6  图片
	IMAGE_BASE64                      // 7  图片 base64
	TABLE                             // 8  表格
	CODE_INLINE                       // 9  代码 内联
	CODE_BLOCK                        // 10  代码 块
	BLOCK_QUOTES                      // 11 引用
	O_LIST                            // 12 有序列表
	U_LIST                            // 13 无序列表
	HR                                // 14 分隔线
	BR                                // 15 换行
	NULL                              // 无
)

type Value

type Value any

Jump to

Keyboard shortcuts

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