mirror of
https://github.com/kovetskiy/mark.git
synced 2026-05-04 06:22:35 +00:00
Move mention macro into a goldmark-parser/renderer
This commit is contained in:
@@ -70,6 +70,18 @@ func (c *ConfluenceExtension) Extend(m goldmark.Markdown) {
|
||||
))
|
||||
}
|
||||
|
||||
if slices.Contains(c.MarkConfig.Features, "mention") {
|
||||
m.Parser().AddOptions(
|
||||
parser.WithInlineParsers(
|
||||
util.Prioritized(cparser.NewMentionParser(), 99),
|
||||
),
|
||||
)
|
||||
|
||||
m.Renderer().AddOptions(renderer.WithNodeRenderers(
|
||||
util.Prioritized(crenderer.NewConfluenceMentionRenderer(c.Stdlib), 100),
|
||||
))
|
||||
}
|
||||
|
||||
m.Parser().AddOptions(parser.WithInlineParsers(
|
||||
// Must be registered with a higher priority than goldmark's linkParser to make sure goldmark doesn't parse
|
||||
// the <ac:*/> tags.
|
||||
|
||||
@@ -64,7 +64,7 @@ func TestCompileMarkdown(t *testing.T) {
|
||||
D2Scale: 1.0,
|
||||
DropFirstH1: false,
|
||||
StripNewlines: false,
|
||||
Features: []string{"mkdocsadmonitions"},
|
||||
Features: []string{"mkdocsadmonitions", "mention"},
|
||||
}
|
||||
|
||||
actual, _ := mark.CompileMarkdown(markdown, lib, filename, cfg)
|
||||
@@ -106,7 +106,7 @@ func TestCompileMarkdownDropH1(t *testing.T) {
|
||||
D2Scale: 1.0,
|
||||
DropFirstH1: true,
|
||||
StripNewlines: false,
|
||||
Features: []string{"mkdocsadmonitions"},
|
||||
Features: []string{"mkdocsadmonitions", "mention"},
|
||||
}
|
||||
|
||||
actual, _ := mark.CompileMarkdown(markdown, lib, filename, cfg)
|
||||
@@ -137,7 +137,7 @@ func TestCompileMarkdownStripNewlines(t *testing.T) {
|
||||
}
|
||||
var variant string
|
||||
switch filename {
|
||||
case "testdata/quotes.md", "testdata/codes.md", "testdata/newlines.md", "testdata/macro-include.md", "testdata/admonitions.md":
|
||||
case "testdata/quotes.md", "testdata/codes.md", "testdata/newlines.md", "testdata/macro-include.md", "testdata/admonitions.md", "testdata/mention.md":
|
||||
variant = "-stripnewlines"
|
||||
default:
|
||||
variant = ""
|
||||
@@ -150,7 +150,7 @@ func TestCompileMarkdownStripNewlines(t *testing.T) {
|
||||
D2Scale: 1.0,
|
||||
DropFirstH1: false,
|
||||
StripNewlines: true,
|
||||
Features: []string{"mkdocsadmonitions"},
|
||||
Features: []string{"mkdocsadmonitions", "mention"},
|
||||
}
|
||||
|
||||
actual, _ := mark.CompileMarkdown(markdown, lib, filename, cfg)
|
||||
|
||||
Reference in New Issue
Block a user