mirror of https://gitee.com/answerdev/answer.git
Merge branch 'feat/cut-text' into 'test'
Feat/cut text See merge request opensource/answer!215
This commit is contained in:
commit
5c90f99397
|
@ -17,8 +17,8 @@ func ClearText(html string) (text string) {
|
|||
re *regexp.Regexp
|
||||
codeReg = `(?ism)<(pre)>.*<\/pre>`
|
||||
codeRepl = "{code...}"
|
||||
linkReg = `(?ism)<a.*?[^<]>.*?<\/a>`
|
||||
linkRepl = "[link]"
|
||||
linkReg = `(?ism)<a.*?[^<]>(.*)?<\/a>`
|
||||
linkRepl = " [$1] "
|
||||
spaceReg = ` +`
|
||||
spaceRepl = " "
|
||||
)
|
||||
|
|
|
@ -17,8 +17,8 @@ func TestClearText(t *testing.T) {
|
|||
assert.Equal(t, expected, clearedText)
|
||||
|
||||
// test link clear text
|
||||
expected = "hello[link]"
|
||||
clearedText = ClearText("<p>hello<a href=\"http://example.com/\">example.com</a></p>")
|
||||
expected = "hello [example.com]"
|
||||
clearedText = ClearText("<p>hello <a href=\"http://example.com/\">example.com</a></p>")
|
||||
assert.Equal(t, expected, clearedText)
|
||||
clearedText = ClearText("<p>hello<a href=\"https://example.com/\">example.com</a></p>")
|
||||
assert.Equal(t, expected, clearedText)
|
||||
|
|
Loading…
Reference in New Issue