1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-13 22:00:27 +00:00
mycorrhiza/markup/paragraph_test.go

51 lines
2.3 KiB
Go
Raw Normal View History

2020-10-30 13:25:48 +00:00
package markup
import (
"fmt"
"testing"
)
/*
func TestGetTextNode(t *testing.T) {
tests := [][]string{
// input textNode rest
{"barab", "barab", ""},
{"test, ", "test", ", "},
{"/test/", "", "/test/"},
{"\\/test/", "/test", "/"},
{"test \\/ar", "test /ar", ""},
{"test //italian// test", "test ", "//italian// test"},
}
for _, triplet := range tests {
a, b := getTextNode([]byte(triplet[0]))
if a != triplet[1] || string(b) != triplet[2] {
t.Error(fmt.Sprintf("Wanted: %q\nGot: %q %q", triplet, a, b))
}
}
}
*/
func TestParagraphToHtml(t *testing.T) {
tests := [][]string{
{"a simple paragraph", "a simple paragraph"},
{"//italic//", "<em>italic</em>"},
{"Embedded //italic//", "Embedded <em>italic</em>"},
{"double //italian// //text//", "double <em>italian</em> <em>text</em>"},
{"it has `mono`", "it has <code>mono</code>"},
2020-11-11 17:42:31 +00:00
{"it has ~~strike~~", "it has <s>strike</s>"},
2020-11-03 15:41:50 +00:00
{"this is a left **bold", "this is a left <strong>bold</strong>"},
2020-10-30 13:25:48 +00:00
{"this line has a ,comma, two of them", "this line has a ,comma, two of them"},
{"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."},
2020-11-04 17:42:02 +00:00
{"A [[simple]] link", `A <a href="/page/simple" class="wikilink_internal">simple</a> link`},
2020-10-30 13:25:48 +00:00
}
for _, test := range tests {
2020-11-04 17:42:02 +00:00
if ParagraphToHtml("Apple", test[0]) != test[1] {
t.Error(fmt.Sprintf("%q: Wanted %q, got %q", test[0], test[1], ParagraphToHtml("Apple", test[0])))
2020-10-30 13:25:48 +00:00
}
}
}
2020-11-04 17:42:02 +00:00
func init() {
HyphaExists = func(_ string) bool { return true }
}