🎨 Supports disabling Markdown * and _ syntax input https://github.com/siyuan-note/siyuan/issues/11206

This commit is contained in:
Daniel 2024-09-13 11:18:58 +08:00
parent 0309e1772e
commit f50c0d606d
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
16 changed files with 99 additions and 14 deletions

View file

@ -10,7 +10,7 @@ require (
github.com/88250/epub v0.0.0-20230830085737-c19055cd1f48
github.com/88250/go-humanize v0.0.0-20240424102817-4f78fac47ea7
github.com/88250/gulu v1.2.3-0.20240612035750-c9cf5f7a4d02
github.com/88250/lute v1.7.7-0.20240912031742-019dc0c2f23a
github.com/88250/lute v1.7.7-0.20240913030339-dd8f3f4ef1fd
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1
github.com/ClarkThan/ahocorasick v0.0.0-20231011042242-30d1ef1347f4

View file

@ -14,8 +14,8 @@ github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950 h1:Pa5hMiBceT
github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/88250/gulu v1.2.3-0.20240612035750-c9cf5f7a4d02 h1:3e5+yobj655pTeKOYMbJrnc1mE51ZkbXIxquTYZuYCY=
github.com/88250/gulu v1.2.3-0.20240612035750-c9cf5f7a4d02/go.mod h1:MUfzyfmbPrRDZLqxc7aPrVYveatTHRfoUa5TynPS0i8=
github.com/88250/lute v1.7.7-0.20240912031742-019dc0c2f23a h1:LKuQgW8p6QdhsGOGVOupcR+zya2peo6VuD1aXpEgQ5I=
github.com/88250/lute v1.7.7-0.20240912031742-019dc0c2f23a/go.mod h1:VDAzL8b+oCh+e3NAlmwwLzC53ten0rZlS8NboB7ljtk=
github.com/88250/lute v1.7.7-0.20240913030339-dd8f3f4ef1fd h1:NeJKjnczuhE6DWjXQe4xDi2LNC+xoEEjZAPDnYj++PQ=
github.com/88250/lute v1.7.7-0.20240913030339-dd8f3f4ef1fd/go.mod h1:VDAzL8b+oCh+e3NAlmwwLzC53ten0rZlS8NboB7ljtk=
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c h1:Dl/8S9iLyPMTElnWIBxmjaLiWrkI5P4a21ivwAn5pU0=
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c/go.mod h1:S5YT38L/GCjVjmB4PB84PymA1qfopjEhfhTNQilLpv4=
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY=

View file

@ -26,17 +26,21 @@ import (
// MarkdownSettings 运行时 Markdown 配置。
var MarkdownSettings = &Markdown{
InlineSup: true,
InlineSub: true,
InlineTag: true,
InlineMath: true,
InlineAsterisk: true,
InlineUnderscore: true,
InlineSup: true,
InlineSub: true,
InlineTag: true,
InlineMath: true,
}
type Markdown struct {
InlineSup bool `json:"inlineSup"` // 是否启用行级上标
InlineSub bool `json:"inlineSub"` // 是否启用行级下标
InlineTag bool `json:"inlineTag"` // 是否启用行级标签
InlineMath bool `json:"inlineMath"` // 是否启用行级公式
InlineAsterisk bool `json:"inlineAsterisk"` // 是否启用行级 * 语法
InlineUnderscore bool `json:"inlineUnderscore"` // 是否启用行级 _ 语法
InlineSup bool `json:"inlineSup"` // 是否启用行级上标
InlineSub bool `json:"inlineSub"` // 是否启用行级下标
InlineTag bool `json:"inlineTag"` // 是否启用行级标签
InlineMath bool `json:"inlineMath"` // 是否启用行级公式
}
func NewLute() (ret *lute.Lute) {
@ -51,6 +55,8 @@ func NewLute() (ret *lute.Lute) {
ret.SetImgPathAllowSpace(true)
ret.SetGitConflict(true)
ret.SetMark(true)
ret.SetInlineAsterisk(MarkdownSettings.InlineAsterisk)
ret.SetInlineUnderscore(MarkdownSettings.InlineUnderscore)
ret.SetSup(MarkdownSettings.InlineSup)
ret.SetSub(MarkdownSettings.InlineSub)
ret.SetTag(MarkdownSettings.InlineTag)
@ -84,6 +90,8 @@ func NewStdLute() (ret *lute.Lute) {
ret.SetGFMAutoLink(false) // 导入 Markdown 时不自动转换超链接 https://github.com/siyuan-note/siyuan/issues/7682
ret.SetImgPathAllowSpace(true)
ret.SetInlineMathAllowDigitAfterOpenMarker(true) // Formula parsing supports $ followed by numbers when importing Markdown https://github.com/siyuan-note/siyuan/issues/8362
ret.SetInlineAsterisk(MarkdownSettings.InlineAsterisk)
ret.SetInlineUnderscore(MarkdownSettings.InlineUnderscore)
ret.SetSup(MarkdownSettings.InlineSup)
ret.SetSub(MarkdownSettings.InlineSub)
ret.SetTag(MarkdownSettings.InlineTag)