mirror of
https://github.com/kovetskiy/mark.git
synced 2025-04-24 05:42:40 +08:00
Fix "<ac:*>" tag rendering
Extend the existing workaround to avoid HTML element escaping to handle more variants.
This commit is contained in:
parent
98e15ed7ff
commit
238ae29b59
@ -437,14 +437,14 @@ func (r *ConfluenceRenderer) renderCodeBlock(writer util.BufWriter, source []byt
|
||||
func CompileMarkdown(markdown []byte, stdlib *stdlib.Lib) string {
|
||||
log.Tracef(nil, "rendering markdown:\n%s", string(markdown))
|
||||
|
||||
colon := regexp.MustCompile(`---bf-COLON---`)
|
||||
colon := []byte("---bf-COLON---")
|
||||
|
||||
tags := regexp.MustCompile(`<(/?ac):(\S+?)>`)
|
||||
tags := regexp.MustCompile(`</?ac:[^>]+>`)
|
||||
|
||||
markdown = tags.ReplaceAll(
|
||||
markdown,
|
||||
[]byte(`<$1`+colon.String()+`$2>`),
|
||||
)
|
||||
for _, sm := range tags.FindAll(markdown, -1) {
|
||||
// Replace the colon in all "<ac:*>" tags with the colon bytes to avoid having Goldmark escape the HTML output.
|
||||
markdown = bytes.ReplaceAll(markdown, sm, bytes.ReplaceAll(sm, []byte(":"), colon))
|
||||
}
|
||||
|
||||
converter := goldmark.New(
|
||||
goldmark.WithExtensions(
|
||||
@ -472,7 +472,8 @@ func CompileMarkdown(markdown []byte, stdlib *stdlib.Lib) string {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
html := colon.ReplaceAll(buf.Bytes(), []byte(`:`))
|
||||
// Restore all the colons we previously replaced.
|
||||
html := bytes.ReplaceAll(buf.Bytes(), colon, []byte(":"))
|
||||
|
||||
log.Tracef(nil, "rendered markdown to html:\n%s", string(html))
|
||||
|
||||
|
6
pkg/mark/testdata/macro-include.html
vendored
Normal file
6
pkg/mark/testdata/macro-include.html
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
<p><foo>bar</foo></p>
|
||||
<ac:structured-macro ac:name="info">
|
||||
<ac:parameter ac:name="icon">true</ac:parameter>
|
||||
<ac:parameter ac:name="title">Attention</ac:parameter>
|
||||
<ac:rich-text-body>This is an info!</ac:rich-text-body>
|
||||
</ac:structured-macro>
|
7
pkg/mark/testdata/macro-include.md
vendored
Normal file
7
pkg/mark/testdata/macro-include.md
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
<foo>bar</foo>
|
||||
|
||||
<ac:structured-macro ac:name="info">
|
||||
<ac:parameter ac:name="icon">true</ac:parameter>
|
||||
<ac:parameter ac:name="title">Attention</ac:parameter>
|
||||
<ac:rich-text-body>This is an info!</ac:rich-text-body>
|
||||
</ac:structured-macro>
|
Loading…
x
Reference in New Issue
Block a user