Skip to content

Commit

Permalink
ToPlain fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sdfsdhgjkbmnmxc committed Dec 5, 2020
1 parent e3548b6 commit 23876f0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
21 changes: 11 additions & 10 deletions tdmarkup/conv.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,17 @@ func ToPlain(s string, e []tdproto.MarkupEntity, opts *ToPlainOpts) string {
}
return []rune("> "), middle, []rune("\n")
case tdproto.Link:
for _, prefix := range [...]string{
"tadateam://",
"tel:",
"mailto:",
} {
if strings.HasPrefix(e.Url, prefix) {
return []rune(""), []rune(e.Repl), []rune("")
}
}
return []rune(""), []rune(e.Url), []rune("")
//for _, prefix := range [...]string{
// "tadateam://",
// "tel:",
// "mailto:",
//} {
// if strings.HasPrefix(e.Url, prefix) {
// return []rune(""), []rune(e.Repl), []rune("")
// }
//}
//return []rune(""), []rune(e.Url), []rune("")
return []rune(""), []rune(e.Repl), []rune("")
case tdproto.Time:
t := mustTime(e.Time)
if loc := opts.Location; loc != nil {
Expand Down
17 changes: 15 additions & 2 deletions tdmarkup/testdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ var MarkupTestCases = []struct {
Title: "link only",
Raw: "123 https://ya.ru 456",
Html: `123 <a href="https://ya.ru">ya.ru</a> 456`,
Plain: `123 https://ya.ru 456`,
Plain: `123 ya.ru 456`,
Links: []tdproto.MessageLink{
{
Pattern: "https://ya.ru",
Expand All @@ -258,7 +258,7 @@ var MarkupTestCases = []struct {
Title: "link only with trailing slash",
Raw: "123 https://ya.ru/? 456",
Html: `123 <a href="https://ya.ru">ya.ru</a> 456`,
Plain: "123 https://ya.ru 456",
Plain: "123 ya.ru 456",
Links: []tdproto.MessageLink{
{
Pattern: "https://ya.ru/?",
Expand All @@ -267,6 +267,19 @@ var MarkupTestCases = []struct {
},
},
},
{
Title: "manage.py",
Raw: "123 manage.py 456",
Html: `123 <a href="http://manage.py">manage.py</a> 456`,
Plain: "123 manage.py 456",
Links: []tdproto.MessageLink{
{
Pattern: "manage.py",
Url: "http://manage.py",
Text: "manage.py",
},
},
},
{
Title: "tag",
Raw: "<br>",
Expand Down

0 comments on commit 23876f0

Please sign in to comment.