Documentation
¶
Overview ¶
Lute 是一款对中文语境优化的 Markdown 引擎,支持 Go 和 JavaScript。
Index ¶
- Constants
- func FormatNode(node *ast.Node, parseOptions *parse.Options, renderOptions *render.Options) string
- func IndentOrder(orderListItemLine string) int
- func RenderNodeVditorIRBlockDOM(node *ast.Node, parseOptions *parse.Options, renderOptions *render.Options) string
- type Lute
- func (lute *Lute) Format(name string, markdown []byte) (formatted []byte)
- func (lute *Lute) FormatStr(name, markdown string) (formatted string)
- func (lute *Lute) GetEmojis() (ret map[string]string)
- func (lute *Lute) GetLinkBase() string
- func (lute *Lute) GetTerms() map[string]string
- func (lute *Lute) HTML2Markdown(htmlStr string) (markdown string, err error)
- func (lute *Lute) HTML2Md(html string) (markdown string)
- func (lute *Lute) HTML2Text(dom string) string
- func (lute *Lute) HTML2Tree(dom string) (ret *parse.Tree)
- func (lute *Lute) HTML2VditorDOM(sHTML string) (vHTML string)
- func (lute *Lute) HTML2VditorIRBlockDOM(sHTML string) (vHTML string)
- func (lute *Lute) HTML2VditorIRDOM(sHTML string) (vHTML string)
- func (lute *Lute) HTML2VditorSVDOM(sHTML string) (vHTML string)
- func (lute *Lute) IsValidLinkDest(str string) bool
- func (lute *Lute) Markdown(name string, markdown []byte) (html []byte)
- func (lute *Lute) MarkdownStr(name, markdown string) (html string)
- func (lute *Lute) Md2HTML(markdown string) (sHTML string)
- func (lute *Lute) Md2VditorDOM(markdown string) (vHTML string)
- func (lute *Lute) Md2VditorIRBlockDOM(markdown string) (vHTML string)
- func (lute *Lute) Md2VditorIRDOM(markdown string) (vHTML string)
- func (lute *Lute) Md2VditorSVDOM(markdown string) (vHTML string)
- func (lute *Lute) PutEmojis(emojiMap map[string]string)
- func (lute *Lute) PutTerms(termMap map[string]string)
- func (lute *Lute) RemoveEmoji(str string) string
- func (lute *Lute) RenderEChartsJSON(markdown string) (json string)
- func (lute *Lute) RenderJSON(markdown string) (json string)
- func (lute *Lute) RenderKityMinderJSON(markdown string) (json string)
- func (lute *Lute) SetAutoSpace(b bool)
- func (lute *Lute) SetBlockRef(b bool)
- func (lute *Lute) SetChineseParagraphBeginningSpace(b bool)
- func (lute *Lute) SetCodeSyntaxHighlight(b bool)
- func (lute *Lute) SetCodeSyntaxHighlightDetectLang(b bool)
- func (lute *Lute) SetCodeSyntaxHighlightInlineStyle(b bool)
- func (lute *Lute) SetCodeSyntaxHighlightLineNum(b bool)
- func (lute *Lute) SetCodeSyntaxHighlightStyleName(name string)
- func (lute *Lute) SetEmoji(b bool)
- func (lute *Lute) SetEmojiSite(emojiSite string)
- func (lute *Lute) SetEmojis(emojis map[string]string)
- func (lute *Lute) SetFixTermTypo(b bool)
- func (lute *Lute) SetFootnotes(b bool)
- func (lute *Lute) SetGFMAutoLink(b bool)
- func (lute *Lute) SetGFMStrikethrough(b bool)
- func (lute *Lute) SetGFMTable(b bool)
- func (lute *Lute) SetGFMTaskListItem(b bool)
- func (lute *Lute) SetGFMTaskListItemClass(class string)
- func (lute *Lute) SetGitConflict(b bool)
- func (lute *Lute) SetHeadingAnchor(b bool)
- func (lute *Lute) SetHeadingID(b bool)
- func (lute *Lute) SetImageLazyLoading(dataSrc string)
- func (lute *Lute) SetImgPathAllowSpace(b bool)
- func (lute *Lute) SetInlineMathAllowDigitAfterOpenMarker(b bool)
- func (lute *Lute) SetJSRenderers(options map[string]map[string]*js.Object)
- func (lute *Lute) SetKramdownBlockIAL(b bool)
- func (lute *Lute) SetKramdownIAL(b bool)
- func (lute *Lute) SetKramdownIALIDRenderName(name string)
- func (lute *Lute) SetKramdownSpanIAL(b bool)
- func (lute *Lute) SetLinkBase(linkBase string)
- func (lute *Lute) SetLinkPrefix(linkPrefix string)
- func (lute *Lute) SetMark(b bool)
- func (lute *Lute) SetRenderListStyle(b bool)
- func (lute *Lute) SetSanitize(b bool)
- func (lute *Lute) SetSoftBreak2HardBreak(b bool)
- func (lute *Lute) SetSub(b bool)
- func (lute *Lute) SetSup(b bool)
- func (lute *Lute) SetSuperBlock(b bool)
- func (lute *Lute) SetTag(b bool)
- func (lute *Lute) SetTerms(terms map[string]string)
- func (lute *Lute) SetToC(b bool)
- func (lute *Lute) SetVditorCodeBlockPreview(b bool)
- func (lute *Lute) SetVditorHTMLBlockPreview(b bool)
- func (lute *Lute) SetVditorIR(b bool)
- func (lute *Lute) SetVditorMathBlockPreview(b bool)
- func (lute *Lute) SetVditorSV(b bool)
- func (lute *Lute) SetVditorWYSIWYG(b bool)
- func (lute *Lute) SetYamlFrontMatter(b bool)
- func (lute *Lute) Space(text string) string
- func (lute *Lute) SpinVditorDOM(ivHTML string) (ovHTML string)
- func (lute *Lute) SpinVditorIRBlockDOM(ivHTML string) (ovHTML string)
- func (lute *Lute) SpinVditorIRDOM(ivHTML string) (ovHTML string)
- func (lute *Lute) SpinVditorSVDOM(markdown string) (ovHTML string)
- func (lute *Lute) TextBundle(name string, markdown []byte, linkPrefixes []string) (textbundle []byte, originalLinks []string)
- func (lute *Lute) TextBundleStr(name, markdown string, linkPrefixes []string) (textbundle string, originalLinks []string)
- func (lute *Lute) Tree2HTML(tree *parse.Tree, options *render.Options) string
- func (lute *Lute) Tree2VditorIRBlockDOM(tree *parse.Tree, options *render.Options) (vHTML string)
- func (lute *Lute) VditorDOM2HTML(vhtml string) (sHTML string)
- func (lute *Lute) VditorDOM2Md(htmlStr string) (markdown string)
- func (lute *Lute) VditorIRBlockDOM2HTML(vhtml string) (sHTML string)
- func (lute *Lute) VditorIRBlockDOM2Md(htmlStr string) (markdown string)
- func (lute *Lute) VditorIRBlockDOM2StdMd(htmlStr string) (markdown string)
- func (lute *Lute) VditorIRBlockDOM2Text(htmlStr string) (text string)
- func (lute *Lute) VditorIRBlockDOM2TextLen(htmlStr string) int
- func (lute *Lute) VditorIRBlockDOM2Tree(htmlStr string) (ret *parse.Tree, err error)
- func (lute *Lute) VditorIRBlockDOMListCommand(listHTML, command string, param1, param2 string) (vHTML string)
- func (lute *Lute) VditorIRDOM2HTML(vhtml string) (sHTML string)
- func (lute *Lute) VditorIRDOM2Md(htmlStr string) (markdown string)
- type ParseOption
Constants ¶
const Version = "1.7.3"
Variables ¶
This section is empty.
Functions ¶
func FormatNode ¶
FormatNode 使用指定的 options 格式化 node,返回格式化后的 Markdown 文本。
func IndentOrder ¶
Types ¶
type Lute ¶
type Lute struct {
ParseOptions *parse.Options // 解析选项
RenderOptions *render.Options // 渲染选项
HTML2MdRendererFuncs map[ast.NodeType]render.ExtRendererFunc // 用户自定义的 HTML2Md 渲染器函数
HTML2VditorDOMRendererFuncs map[ast.NodeType]render.ExtRendererFunc // 用户自定义的 HTML2VditorDOM 渲染器函数
HTML2VditorIRDOMRendererFuncs map[ast.NodeType]render.ExtRendererFunc // 用户自定义的 HTML2VditorIRDOM 渲染器函数
HTML2VditorIRBlockDOMRendererFuncs map[ast.NodeType]render.ExtRendererFunc // 用户自定义的 HTML2VditorIRBlockDOM 渲染器函数
HTML2VditorSVDOMRendererFuncs map[ast.NodeType]render.ExtRendererFunc // 用户自定义的 HTML2VditorSVDOM 渲染器函数
Md2HTMLRendererFuncs map[ast.NodeType]render.ExtRendererFunc // 用户自定义的 Md2HTML 渲染器函数
Md2VditorDOMRendererFuncs map[ast.NodeType]render.ExtRendererFunc // 用户自定义的 Md2VditorDOM 渲染器函数
Md2VditorIRDOMRendererFuncs map[ast.NodeType]render.ExtRendererFunc // 用户自定义的 Md2VditorIRDOM 渲染器函数
Md2VditorIRBlockDOMRendererFuncs map[ast.NodeType]render.ExtRendererFunc // 用户自定义的 Md2VditorIRBlockDOM 渲染器函数
Md2VditorSVDOMRendererFuncs map[ast.NodeType]render.ExtRendererFunc // 用户自定义的 Md2VditorSVDOM 渲染器函数
}
Lute 描述了 Lute 引擎的顶层使用入口。
func New ¶
func New(opts ...ParseOption) (ret *Lute)
New 创建一个新的 Lute 引擎。
默认启用的解析选项:
- GFM 支持
- 脚注
- 标题自定义 ID
- Emoji 别名替换,比如 :heart: 替换为 ❤️
- YAML Front Matter
默认启用的渲染选项:
- 软换行转硬换行
- 代码块语法高亮
- 中西文间插入空格
- 修正术语拼写
- 标题自定义 ID
func (*Lute) GetLinkBase ¶
func (*Lute) HTML2Markdown ¶
HTML2Markdown 将 HTML 转换为 Markdown。
func (*Lute) HTML2VditorDOM ¶
HTML2VditorDOM 将 HTML 转换为 Vditor DOM,用于所见即所得模式下粘贴。
func (*Lute) HTML2VditorIRBlockDOM ¶
HTML2VditorIRBlockDOM 将 HTML 转换为 Vditor Instant-Rendering Block DOM,用于即时渲染块模式下粘贴。
func (*Lute) HTML2VditorIRDOM ¶
HTML2VditorIRDOM 将 HTML 转换为 Vditor Instant-Rendering DOM,用于即时渲染模式下粘贴。
func (*Lute) HTML2VditorSVDOM ¶
HTML2VditorSVDOM 将 HTML 转换为 Vditor Split-View DOM,用于分屏预览模式下粘贴。
func (*Lute) IsValidLinkDest ¶
IsValidLinkDest 判断 str 是否为合法的链接地址。
func (*Lute) Markdown ¶
Markdown 将 markdown 文本字节数组处理为相应的 html 字节数组。name 参数仅用于标识文本,比如可传入 id 或者标题,也可以传入 ""。
func (*Lute) MarkdownStr ¶
MarkdownStr 接受 string 类型的 markdown 后直接调用 Markdown 进行处理。
func (*Lute) Md2VditorDOM ¶
Md2VditorDOM 将 markdown 转换为 Vditor DOM,用于从源码模式切换至所见即所得模式。
func (*Lute) Md2VditorIRBlockDOM ¶
Md2VditorIRBlockDOM 将 markdown 转换为 Vditor Instant-Rendering Block DOM,用于从源码模式切换至即时渲染块模式。
func (*Lute) Md2VditorIRDOM ¶
Md2VditorIRDOM 将 markdown 转换为 Vditor Instant-Rendering DOM,用于从源码模式切换至即时渲染模式。
func (*Lute) Md2VditorSVDOM ¶
Md2VditorSVDOM 将 markdown 转换为 Vditor Split-View DOM,用于从源码模式切换至分屏预览模式。
func (*Lute) RemoveEmoji ¶
RemoveEmoji 用于删除 str 中的 Emoji Unicode。
func (*Lute) RenderEChartsJSON ¶
RenderEChartsJSON 用于渲染 ECharts JSON 格式数据。
func (*Lute) RenderJSON ¶
RenderJSON 用于渲染 JSON 格式数据。
func (*Lute) RenderKityMinderJSON ¶
RenderKityMinderJSON 用于渲染 KityMinder JSON 格式数据。
func (*Lute) SetAutoSpace ¶
func (*Lute) SetBlockRef ¶
func (*Lute) SetChineseParagraphBeginningSpace ¶
func (*Lute) SetCodeSyntaxHighlight ¶
func (*Lute) SetCodeSyntaxHighlightDetectLang ¶
func (*Lute) SetCodeSyntaxHighlightInlineStyle ¶
func (*Lute) SetCodeSyntaxHighlightLineNum ¶
func (*Lute) SetCodeSyntaxHighlightStyleName ¶
func (*Lute) SetEmojiSite ¶
func (*Lute) SetFixTermTypo ¶
func (*Lute) SetFootnotes ¶
func (*Lute) SetGFMAutoLink ¶
func (*Lute) SetGFMStrikethrough ¶
func (*Lute) SetGFMTable ¶
func (*Lute) SetGFMTaskListItem ¶
func (*Lute) SetGFMTaskListItemClass ¶
func (*Lute) SetGitConflict ¶
func (*Lute) SetHeadingAnchor ¶
func (*Lute) SetHeadingID ¶
func (*Lute) SetImageLazyLoading ¶
func (*Lute) SetImgPathAllowSpace ¶
func (*Lute) SetInlineMathAllowDigitAfterOpenMarker ¶
func (*Lute) SetJSRenderers ¶
func (*Lute) SetKramdownBlockIAL ¶
func (*Lute) SetKramdownIAL ¶
func (*Lute) SetKramdownIALIDRenderName ¶
func (*Lute) SetKramdownSpanIAL ¶
func (*Lute) SetLinkBase ¶
func (*Lute) SetLinkPrefix ¶
func (*Lute) SetRenderListStyle ¶
func (*Lute) SetSanitize ¶
func (*Lute) SetSoftBreak2HardBreak ¶
func (*Lute) SetSuperBlock ¶
func (*Lute) SetVditorCodeBlockPreview ¶
func (*Lute) SetVditorHTMLBlockPreview ¶
func (*Lute) SetVditorIR ¶
func (*Lute) SetVditorMathBlockPreview ¶
func (*Lute) SetVditorSV ¶
func (*Lute) SetVditorWYSIWYG ¶
func (*Lute) SetYamlFrontMatter ¶
func (*Lute) SpinVditorDOM ¶
SpinVditorDOM 自旋 Vditor DOM,用于所见即所得模式下的编辑。
func (*Lute) SpinVditorIRBlockDOM ¶
SpinVditorIRBlockDOM 自旋 Vditor Instant-Rendering Block DOM,用于即时渲染块模式下的编辑。
func (*Lute) SpinVditorIRDOM ¶
SpinVditorIRDOM 自旋 Vditor Instant-Rendering DOM,用于即时渲染模式下的编辑。
func (*Lute) SpinVditorSVDOM ¶
SpinVditorSVDOM 自旋 Vditor Split-View DOM,用于分屏预览模式下的编辑。
func (*Lute) TextBundle ¶
func (lute *Lute) TextBundle(name string, markdown []byte, linkPrefixes []string) (textbundle []byte, originalLinks []string)
TextBundle 将 markdown 文本字节数组进行 TextBundle 处理。
func (*Lute) TextBundleStr ¶
func (lute *Lute) TextBundleStr(name, markdown string, linkPrefixes []string) (textbundle string, originalLinks []string)
TextBundle 接受 string 类型的 markdown 后直接调用 TextBundle 进行处理。
func (*Lute) Tree2VditorIRBlockDOM ¶
func (*Lute) VditorDOM2HTML ¶
VditorDOM2HTML 将 Vditor DOM 转换为 HTML,用于 Vditor.getHTML() 接口。
func (*Lute) VditorDOM2Md ¶
VditorDOM2Md 将 Vditor DOM 转换为 markdown,用于从所见即所得模式切换至源码模式。
func (*Lute) VditorIRBlockDOM2HTML ¶
VditorIRBlockDOM2HTML 将 Vditor Instant-Rendering Block DOM 转换为 HTML,用于 Vditor.getHTML() 接口。
func (*Lute) VditorIRBlockDOM2Md ¶
VditorIRBlockDOM2Md 将 Vditor Instant-Rendering DOM 转换为 markdown,用于从即时渲染块模式切换至源码模式。
func (*Lute) VditorIRBlockDOM2StdMd ¶
VditorIRBlockDOM2StdMd 将 Vditor Instant-Rendering DOM 转换为标准 markdown,用于复制剪切。
func (*Lute) VditorIRBlockDOM2Text ¶
func (*Lute) VditorIRBlockDOM2TextLen ¶
func (*Lute) VditorIRBlockDOM2Tree ¶
func (*Lute) VditorIRBlockDOMListCommand ¶
func (*Lute) VditorIRDOM2HTML ¶
VditorIRDOM2HTML 将 Vditor Instant-Rendering DOM 转换为 HTML,用于 Vditor.getHTML() 接口。
func (*Lute) VditorIRDOM2Md ¶
VditorIRDOM2Md 将 Vditor Instant-Rendering DOM 转换为 markdown,用于从即时渲染模式切换至源码模式。
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package html implements an HTML5-compliant tokenizer and parser.
|
Package html implements an HTML5-compliant tokenizer and parser. |
|
atom
Package atom provides integer codes (also known as atoms) for a fixed set of frequently occurring HTML strings: tag names and attribute keys such as "p" and "id".
|
Package atom provides integer codes (also known as atoms) for a fixed set of frequently occurring HTML strings: tag names and attribute keys such as "p" and "id". |

