Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func validStart(pos int, input []rune) bool {
}

func validEnd(pos int, input []rune) bool {
// First char is not a valid end char.
// First char is not a valid end char; we do NOT allow empty entities.
// If the end char has a space before it, its not valid either.
if pos == 0 || unicode.IsSpace(input[pos-1]) {
return false
Expand Down
6 changes: 3 additions & 3 deletions commonV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func isClosingTag(in []rune, pos int) bool {
return false
}

func getClosingTag(in []rune, tag string) (int, int) {
func getClosingTag(in []rune, openingTag string, closingTag string) (int, int) {
offset := 0
subtags := 0
for offset < len(in) {
Expand All @@ -164,9 +164,9 @@ func getClosingTag(in []rune, tag string) (int, int) {
}

closingTagIdx := openingTagIdx + 2 + c
if string(in[openingTagIdx+1:closingTagIdx]) == tag { // found a nested tag, this is annoying
if string(in[openingTagIdx+1:closingTagIdx]) == openingTag { // found a nested tag, this is annoying
subtags++
} else if isClosingTag(in, openingTagIdx) && string(in[openingTagIdx+2:closingTagIdx]) == tag {
} else if isClosingTag(in, openingTagIdx) && string(in[openingTagIdx+2:closingTagIdx]) == closingTag {
if subtags == 0 {
return openingTagIdx, closingTagIdx
}
Expand Down
14 changes: 14 additions & 0 deletions common_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package tg_md2html_test

import "github.com/PaulSonOfLars/gotg_md2html"

func testConverter() *tg_md2html.ConverterV2 {
return tg_md2html.NewV2(map[string]string{
"url": "buttonurl",
"text": "buttontext",
}, map[string]string{
"primary": "primary",
"success": "success",
"danger": "danger",
})
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/PaulSonOfLars/gotg_md2html

go 1.19

require github.com/stretchr/testify v1.8.4
require github.com/stretchr/testify v1.11.1

require (
github.com/davecgh/go-spew v1.1.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
Loading