Documentation
¶
Index ¶
- Variables
- func ATXHeadingStart(t *Tree, container *ast.Node) int
- func AddAutoLinkDomainSuffix(suffix string)
- func ApplyHTMLTextSemantics(node *ast.Node, dom *html.Node)
- func ApplyHTMLTextStyle(n *ast.Node, style string)
- func ApplyTableCellRichProjection(cell *ast.Node) error
- func BlockQueryEmbedStart(t *Tree, container *ast.Node) int
- func BlockquoteContinue(blockquote *ast.Node, context *Context) int
- func BlockquoteStart(t *Tree, container *ast.Node) int
- func CalloutContinue(callout *ast.Node, context *Context) int
- func CalloutStart(t *Tree, container *ast.Node) int
- func CloneTableCellInline(node *ast.Node) *ast.Node
- func CodeBlockContinue(codeBlock *ast.Node, context *Context) int
- func ContainTextMark(node *ast.Node, dataTypes ...string) bool
- func CustomBlockContinue(customBlock *ast.Node, context *Context) int
- func CustomBlockStart(t *Tree, container *ast.Node) int
- func FenceCodeBlockStart(t *Tree, container *ast.Node) int
- func FootnotesContinue(footnotesDef *ast.Node, context *Context) int
- func FootnotesStart(t *Tree, container *ast.Node) int
- func GitConflictContinue(gitConflictBlock *ast.Node, context *Context) int
- func GitConflictStart(t *Tree, container *ast.Node) int
- func HTMLStyleDeclarations(style string) map[string]string
- func HtmlBlockContinue(html *ast.Node, context *Context) int
- func HtmlBlockStart(t *Tree, container *ast.Node) int
- func IAL2Map(ial [][]string) (ret map[string]string)
- func IAL2MapUnEsc(ial [][]string) (ret map[string]string)
- func IAL2Tokens(ial [][]string) []byte
- func IALStart(t *Tree, container *ast.Node) int
- func IALVal(ial *ast.Node, name string) string
- func IALValMap(ial *ast.Node) (ret map[string]string)
- func IndentCodeBlockStart(t *Tree, container *ast.Node) int
- func IsEmoji(str string) bool
- func ListItemContinue(listItem *ast.Node, context *Context) int
- func ListStart(t *Tree, container *ast.Node) int
- func Map2IAL(properties map[string]string) (ret [][]string)
- func MathBlockContinue(mathBlock *ast.Node, context *Context) int
- func MathBlockStart(t *Tree, container *ast.Node) int
- func NestedInlines2FlattedSpans(tree *Tree, isExportMd bool)
- func NestedInlines2FlattedSpansHybrid(tree *Tree, isExportMd bool)
- func NormalizeInlineHTMLTextStyles(tree *Tree)
- func ParagraphContinue(p *ast.Node, context *Context) int
- func ProjectTableCellRich(tree *Tree) *ast.Node
- func ProjectTableCellRichWithSources(tree *Tree) (*ast.Node, map[*ast.Node]*ast.Node)
- func SetSpanIAL(node *ast.Node, n *html.Node)
- func SetTextMarkNode(node *ast.Node, n *html.Node, options *Options)
- func SetextHeadingStart(t *Tree, container *ast.Node) int
- func StyleValue(style string) (ret string)
- func SuperBlockContinue(superBlock *ast.Node, context *Context) int
- func SuperBlockStart(t *Tree, container *ast.Node) int
- func TableCellAlignValue(align, style string) int
- func TableCellStyleAlign(style string) (align int, found bool)
- func TabsStart(t *Tree, container *ast.Node) int
- func TagAttr(tokens []byte) (valid bool, remains, attr, name, val []byte)
- func TextMarks2Inlines(tree *Tree)
- func TextMarks2InlinesWithNestedSyntax(tree *Tree)
- func ThematicBreakStart(t *Tree, container *ast.Node) int
- func Tokens2IAL(tokens []byte) (ret [][]string)
- func YamlFrontMatterContinue(node *ast.Node, context *Context) int
- func YamlFrontMatterStart(t *Tree, container *ast.Node) int
- type Context
- type HTMLTextStyle
- type InlineContext
- type Options
- type Tree
- func (t *Tree) BlockCount() (ret int)
- func (t *Tree) DocBlockCount() (ret int)
- func (t *Tree) EmojiImgTokens(alias, src string) []byte
- func (t *Tree) ExistFootnotesDef() (ret bool)
- func (t *Tree) FindFootnotesDef(label []byte) (pos int, def *ast.Node)
- func (t *Tree) FindLinkRefDefLink(label []byte) (link *ast.Node)
- func (t *Tree) MergeText()
Constants ¶
This section is empty.
Variables ¶
var EmojiAliasUnicode = map[string]string{}/* 2126 elements not displayed */
var EmojiLock = sync.Mutex{}
var EmojiSitePlaceholder = util.StrToBytes("${emojiSite}")
var EmojiUnicodeAlias map[string]string
var MathBlockMarker = util.StrToBytes("$$")
var MathBlockMarkerCaret = util.StrToBytes("$$" + editor.Caret)
var YamlFrontMatterMarker = util.StrToBytes("---")
var YamlFrontMatterMarkerCaret = util.StrToBytes("---" + editor.Caret)
var YamlFrontMatterMarkerCaretNewline = util.StrToBytes("---" + editor.Caret + "\n")
var YamlFrontMatterMarkerNewline = util.StrToBytes("---\n")
Functions ¶
func ATXHeadingStart ¶
ATXHeadingStart 判断 ATX 标题(#)是否开始。
func AddAutoLinkDomainSuffix ¶
func AddAutoLinkDomainSuffix(suffix string)
AddAutoLinkDomainSuffix 添加自动链接解析域名后缀 suffix。
func ApplyHTMLTextSemantics ¶ added in v1.7.8
ApplyHTMLTextSemantics 保留样式文本的 CSS 强调及祖先链接,避免平铺后丢失组合格式。
func ApplyHTMLTextStyle ¶ added in v1.7.8
ApplyHTMLTextStyle 将样式附着到原生文本标记,保留链接及组合格式的数据。
func ApplyTableCellRichProjection ¶ added in v1.7.8
ApplyTableCellRichProjection 仅在源成功解析后刷新派生的行内内容。
func BlockQueryEmbedStart ¶
BlockQueryEmbedStart 判断内容块查询嵌入({{ SELECT * FROM blocks WHERE content LIKE '%待办%' }})是否开始。
func BlockquoteStart ¶
BlockquoteStart 判断引述(>)是否开始。
func CalloutContinue ¶ added in v1.7.7
func CalloutStart ¶ added in v1.7.7
CalloutStart 判断提示块(> [!Note])是否开始。
func CloneTableCellInline ¶ added in v1.7.8
CloneTableCellInline 复制行内节点及其属性,避免投影和源树共享可变节点。
func ContainTextMark ¶ added in v1.7.5
func CustomBlockContinue ¶ added in v1.7.6
func CustomBlockStart ¶ added in v1.7.6
CustomBlockStart 判断围栏自定义块(;;;info)是否开始。
func FenceCodeBlockStart ¶
FenceCodeBlockStart 判断围栏代码块(```)是否开始。
func FootnotesStart ¶
FootnotesStart 判断脚注定义([^label])是否开始。
func GitConflictContinue ¶
func GitConflictStart ¶
判断 Git 冲突标记是否开始。
<<<<<<< HEAD 这里是本地原来的内容 ======= 这里是拉取下来的内容 >>>>>>> feebfeb6bef44cf1384d51cdd7aef7e4197b8180
func HTMLStyleDeclarations ¶ added in v1.7.8
HTMLStyleDeclarations 在引号和括号之外拆分声明,保留同一属性的优先级。
func HtmlBlockStart ¶
HtmlBlockStart 判断 HTML 块(<)是否开始。
func IAL2MapUnEsc ¶
func IAL2Tokens ¶
func IndentCodeBlockStart ¶
IndentCodeBlockStart 判断缩进代码块( code)是否开始。
func MathBlockStart ¶
MathBlockStart 判断数学公式块($$)是否开始。
func NestedInlines2FlattedSpans ¶ added in v1.7.5
NestedInlines2FlattedSpans 将嵌套的行级节点转换为平铺的文本标记节点。 该函数会移除转义节点。
func NestedInlines2FlattedSpansHybrid ¶ added in v1.7.6
NestedInlines2FlattedSpansHybrid 将嵌套的行级节点转换为平铺的文本标记节点。 该函数不会移除转义节点。
func NormalizeInlineHTMLTextStyles ¶ added in v1.7.8
func NormalizeInlineHTMLTextStyles(tree *Tree)
NormalizeInlineHTMLTextStyles 只转换配对的行内标签,代码块和未闭合标签保持原样。
func ProjectTableCellRich ¶ added in v1.7.8
ProjectTableCellRich 将片段转换成行内节点,保留图片、引用、样式以及可读的列表标记。
func ProjectTableCellRichWithSources ¶ added in v1.7.8
ProjectTableCellRichWithSources 同时记录行内节点的来源,供资源和引用改写同步回富文本源。
func SetTextMarkNode ¶ added in v1.7.5
func SetextHeadingStart ¶
SetextHeadingStart 判断 Setext 标题(- =)是否开始。
func StyleValue ¶ added in v1.7.5
func SuperBlockStart ¶
SuperBlockStart 判断超级块({{{ blocks }}})是否开始。
func TableCellAlignValue ¶ added in v1.7.8
TableCellAlignValue 兼容旧的 align 属性,并以行内样式为准。
func TableCellStyleAlign ¶ added in v1.7.8
TableCellStyleAlign 读取单元格行内样式中的水平对齐方式。
func TextMarks2Inlines ¶ added in v1.7.7
func TextMarks2Inlines(tree *Tree)
func TextMarks2InlinesWithNestedSyntax ¶ added in v1.7.8
func TextMarks2InlinesWithNestedSyntax(tree *Tree)
TextMarks2InlinesWithNestedSyntax 仅转换包含可平铺 Markdown 行级语法的文本标记。
func ThematicBreakStart ¶
判断分隔线(--- ***)是否开始。
func Tokens2IAL ¶
Types ¶
type Context ¶
type Context struct {
Tree *Tree // 关联的语法树
ParseOption *Options // 解析选项
Tip *ast.Node // 末梢节点
// contains filtered or unexported fields
}
Context 用于维护块级元素解析过程中使用到的公共数据。
func (*Context) TipAppendChild ¶
type HTMLTextStyle ¶ added in v1.7.8
HTMLTextStyle 只保存可映射到文本标记的外部样式,不携带页面布局或资源引用。
func HTMLNodeTextStyle ¶ added in v1.7.8
func HTMLNodeTextStyle(n *html.Node) HTMLTextStyle
func ResolveHTMLTextStyle ¶ added in v1.7.8
func ResolveHTMLTextStyle(n *html.Node, parent HTMLTextStyle) HTMLTextStyle
ResolveHTMLTextStyle 将相对字号按父级计算;没有绝对基准时保留相对编辑器字号的 em 值。
func (HTMLTextStyle) CSS ¶ added in v1.7.8
func (s HTMLTextStyle) CSS() string
type InlineContext ¶
type InlineContext struct {
// contains filtered or unexported fields
}
InlineContext 描述了行级元素解析上下文。
type Options ¶
type Options struct {
// DisableTableCellRich 禁止在富文本片段内部递归展开单元格富文本。
DisableTableCellRich bool
// GFMTable 设置是否打开“GFM 表”支持。
GFMTable bool
// GFMTaskListItem 设置是否打开“GFM 任务列表项”支持。
GFMTaskListItem bool
// GFMStrikethrough 设置是否打开“GFM 删除线”支持。
GFMStrikethrough bool
// GFMStrikethrough1 设置是否打开“GFM 删除线”一个标记符 ~ 支持。
// GFM 删除线支持两个标记符 ~~,这个选项用于支持一个标记符的删除线。
GFMStrikethrough1 bool
// FullWidthStrikethrough 设置是否将两个全角波浪号作为删除线标记符支持。
FullWidthStrikethrough bool
// GFMAutoLink 设置是否打开“GFM 自动链接”支持。
GFMAutoLink bool
// Footnotes 设置是否打开“脚注”支持。
Footnotes bool
// HeadingID 设置是否打开“自定义标题 ID”支持。
HeadingID bool
// ToC 设置是否打开“目录”支持。
ToC bool
// Emoji 设置是否对 Emoji 别名替换为原生 Unicode 字符。
Emoji bool
// AliasEmoji 存储 ASCII 别名到表情 Unicode 映射。
AliasEmoji map[string]string
// EmojiAlias 存储表情 Unicode 到 ASCII 别名映射。
EmojiAlias map[string]string
// EmojiSite 设置图片 Emoji URL 的路径前缀。
EmojiSite string
// Vditor 所见即所得支持。
VditorWYSIWYG bool
// Vditor 即时渲染支持。
VditorIR bool
// Vditor 分屏预览支持。
VditorSV bool
// Protyle 所见即所得支持。
ProtyleWYSIWYG bool
// ProtyleWYSIWYGAutoLink 设置是否在 Protyle 所见即所得模式下启用自动链接解析。
ProtyleWYSIWYGAutoLink bool
// InlineMath 设置是否开启行级公式 $foo$ 支持。
InlineMath bool
// InlineMathAllowDigitAfterOpenMarker 设置内联数学公式是否允许起始 $ 后紧跟数字 https://github.com/b3log/lute/issues/38
InlineMathAllowDigitAfterOpenMarker bool
// Setext 设置是否解析 Setext 标题 https://github.com/88250/lute/issues/50
Setext bool
// YamlFrontMatter 设置是否开启 YAML Front Matter 支持。
YamlFrontMatter bool
// BlockRef 设置是否开启内容块引用支持。
BlockRef bool
// FileAnnotationRef 设置是否开启文件注解引用支持。
FileAnnotationRef bool
// Mark 设置是否打开 ==标记== 支持。
Mark bool
// KramdownBlockIAL 设置是否打开 kramdown 块级内联属性列表支持。 https://kramdown.gettalong.org/syntax.html#inline-attribute-lists
KramdownBlockIAL bool
// KramdownSpanIAL 设置是否打开 kramdown 行级内联属性列表支持。
KramdownSpanIAL bool
// Tag 设置是否开启 #标签# 支持。
Tag bool
// ImgPathAllowSpace 设置是否支持图片路径带空格。
ImgPathAllowSpace bool
// SuperBlock 设置是否支持超级块。 https://github.com/88250/lute/issues/111
SuperBlock bool
// CustomBlock 设置是否支持自定义块。 https://github.com/siyuan-note/siyuan/issues/8418
CustomBlock bool
// Sup 设置是否打开 ^上标^ 支持。
Sup bool
// Sub 设置是否打开 ~下标~ 支持。
Sub bool
// InlineAsterisk 设置是否打开行级 * 语法支持(*foo* 和 **foo**)。
InlineAsterisk bool
// InlineUnderscore 设置是否打开行级 _ 语法支持(_foo_ 和 __foo__)。
InlineUnderscore bool
// GitConflict 设置是否打开 Git 冲突标记支持。
GitConflict bool
// LinkRef 设置是否打开“链接引用”支持。
LinkRef bool
// IndentCodeBlock 设置是否打开“缩进代码块”支持。
IndentCodeBlock bool
// ParagraphBeginningSpace 设置是否打开“段首空格”支持。
ParagraphBeginningSpace bool
// DataImage 设置是否打开  形式的图片支持。
DataImage bool
// TextMark 设置是否打开通用行级节点解析支持。
TextMark bool
// HTMLTag2TextMark 设置是否打开 HTML 某些标签解析为 TextMark 节点支持。
// 目前仅支持 <u>、<kbd>、<sub>、<sup>、<strong>/<b>、<em>/<i>、<s>/<del>/<strike> 和 <mark>。
//
// * h2m 时就算禁用行级语法,只要启用 HTMLTag2TextMark 则依然转换为 md 标记符,因为 h2m 不走 parse
// * 走 parse 时如果遇到 html 标签且 HTMLTag2TextMark 开启则转换为 TextMark 节点
// 所以最终以上两种情况都相当于启用行级语法渲染 Protyle DOM
HTMLTag2TextMark bool
// Spin 设置是否打开自旋解析支持,该选项仅用于 Spin 内部过程,设置时请注意使用场景。
//
// 该选项的引入主要为了解决 finalParseBlockIAL 过程中是否需要移动 IAL 节点的问题,只有处于自旋过程中才需要移动 IAL 节点
// 其他情况,比如标题块软换行分块 https://github.com/siyuan-note/siyuan/issues/5723 以及软换行空行分块 https://ld246.com/article/1703839312585
// 的场景需要移动 IAL 节点,但是 API 输入 markdown https://github.com/siyuan-note/siyuan/issues/6725)无需移动
Spin bool
// HTML2MarkdownAttrs 设置将 HTML 转换为 Markdown 时保留的属性列表
HTML2MarkdownAttrs []string
// Callout 设置是否开启提示块支持。
Callout bool
// Tabs 设置是否开启页签容器支持。
Tabs bool
// KeepEscaped 设置是否保留转义内容(不进行反转义)。
KeepEscaped bool
// ArbitraryTaskListItemMarker 设置是否打开"任务列表任意标记符"支持。
// 默认仅支持 [ ]、[x] 和 [X],开启后支持 [/]、[>]、[-]、[!] 等任意标记符。
ArbitraryTaskListItemMarker bool
// EnsureListItemParagraph 为 true 时,空列表项下创建子列表前会补一个空段落,
// 避免出现列表项下直接挂列表的结构 https://github.com/siyuan-note/siyuan/issues/17890
EnsureListItemParagraph bool
}
Options 描述了解析选项。
func NewOptions ¶
func NewOptions() *Options
func TableCellRichOptions ¶ added in v1.7.8
func TableCellRichOptions() *Options
TableCellRichOptions 固定富文本存储语法,不受当前编辑器的 Markdown 开关影响。
func (*Options) IsValidTaskListItemMarker ¶ added in v1.7.7
IsValidTaskListItemMarker 判断 marker 是否是合法的任务列表项标记符。 当 ArbitraryTaskListItemMarker 开启时接受任意非 [] 字符,否则仅接受 ' '、'x' 和 'X'。
type Tree ¶
type Tree struct {
Root *ast.Node // 根节点
Context *Context // 块级解析上下文
Name string // 名称
ID string // ID
Box string // 容器
Path string // 路径
HPath string // 人类可读的路径
Marks []string // 文本标记
Created int64 // 创建时间
Updated int64 // 更新时间
Hash string // 内容哈希
// contains filtered or unexported fields
}
Tree 描述了 Markdown 抽象语法树结构。
func ParseTableCellRich ¶ added in v1.7.8
func ParseTableCellRich(rich *ast.TableCellRich) (tree *Tree, err error)
ParseTableCellRich 解析受支持的片段;片段中的块身份不进入文档块树。
func (*Tree) BlockCount ¶
func (*Tree) DocBlockCount ¶
func (*Tree) EmojiImgTokens ¶
func (*Tree) ExistFootnotesDef ¶ added in v1.7.7
func (*Tree) FindFootnotesDef ¶
Source Files
¶
- auto_link.go
- block_query_embed.go
- block_ref.go
- block_start.go
- blockquote.go
- blocks.go
- callout.go
- code_block.go
- code_span.go
- custom_block.go
- delimiter.go
- emoji.go
- emoji_map.go
- file_annotation_ref.go
- footnotes.go
- gitconflict.go
- heading.go
- heading_id.go
- html_block.go
- html_text_style.go
- html_text_style_inline.go
- image.go
- inline.go
- inline_attribute_list.go
- inline_html.go
- inline_link.go
- inline_math.go
- inlines.go
- link.go
- linkrefdef_case_fold.go
- linkrefdef_index.go
- list.go
- math_block.go
- paragraph.go
- parse.go
- super_block.go
- table.go
- table_rich.go
- table_rich_style.go
- tabs.go
- text.go
- text_mark_delimiters.go
- thematic_break.go
- toc.go
- transform.go
- yaml_front_matter.go