mirror of
https://github.com/kovetskiy/mark.git
synced 2025-06-07 23:12:42 +08:00
use AutoLink rule to all links except ac: namespace
This commit is contained in:
parent
07926611cf
commit
f0e00468e9
@ -5,9 +5,9 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
bf "github.com/kovetskiy/blackfriday/v2"
|
||||
"github.com/kovetskiy/mark/pkg/mark/stdlib"
|
||||
"github.com/reconquest/pkg/log"
|
||||
bf "github.com/kovetskiy/blackfriday/v2"
|
||||
)
|
||||
|
||||
type ConfluenceRenderer struct {
|
||||
@ -78,7 +78,8 @@ func (renderer ConfluenceRenderer) RenderNode(
|
||||
|
||||
// compileMarkdown will replace tags like <ac:rich-tech-body> with escaped
|
||||
// equivalent, because bf markdown parser replaces that tags with
|
||||
// <a href="ac:rich-text-body">ac:rich-text-body</a> for whatever reason.
|
||||
// <a href="ac:rich-text-body">ac:rich-text-body</a> because of the autolink
|
||||
// rule.
|
||||
func CompileMarkdown(
|
||||
markdown []byte,
|
||||
stdlib *stdlib.Lib,
|
||||
@ -87,7 +88,7 @@ func CompileMarkdown(
|
||||
|
||||
colon := regexp.MustCompile(`---bf-COLON---`)
|
||||
|
||||
tags := regexp.MustCompile(`<(/?\S+?):(\S+?)>`)
|
||||
tags := regexp.MustCompile(`<(/?ac):(\S+?)>`)
|
||||
|
||||
markdown = tags.ReplaceAll(
|
||||
markdown,
|
||||
|
3
pkg/mark/testdata/links.html
vendored
Normal file
3
pkg/mark/testdata/links.html
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
<p>Use <a href="https://example.com">https://example.com</a></p>
|
||||
|
||||
<p>Use <ac:rich-text-body>aaa</ac:rich-text-body></p>
|
3
pkg/mark/testdata/links.md
vendored
Normal file
3
pkg/mark/testdata/links.md
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
Use <https://example.com>
|
||||
|
||||
Use <ac:rich-text-body>aaa</ac:rich-text-body>
|
Loading…
x
Reference in New Issue
Block a user