package nip54 import ( "fmt" "strings" "testing" ) func TestNormalization(t *testing.T) { for _, vector := range []struct { before string after string }{ {" hello ", "hello"}, {"Goodbye", "goodbye"}, {"the long and winding road / that leads to your door", "the-long-and-winding-road---that-leads-to-your-door"}, {"it's 平仮名", "it-s-平仮名"}, } { if norm := NormalizeIdentifier(vector.before); norm != vector.after { fmt.Println([]byte(vector.after), []byte(norm)) t.Fatalf("%s: %s != %s", vector.before, norm, vector.after) } } } func TestArticleAsHTML(t *testing.T) { tests := []struct { name string input string contains []string }{ { name: "simple paragraph", input: "Hello world", contains: []string{"
", "Hello world", "
"}, }, { name: "emphasis", input: "*Hello* _world_", contains: []string{"", "Hello", "", "", "world", ""}, }, { name: "heading", input: "# Title", contains: []string{"This is *regular not strong* emphasis
"}}, {name: "example 2", input: "*This is _strong* not regular_ emphasis", contains: []string{"This is _strong not regular_ emphasis
"}}, {name: "example 3", input: "[Link *](url)*", contains: []string{""}}, {name: "example 4", input: "*Emphasis [*](url)", contains: []string{"Emphasis [](url)
"}}, {name: "example 5", input: "_This is *strong within* regular emphasis_", contains: []string{"This is strong within regular emphasis
"}}, {name: "example 6", input: "{_Emphasized_}\n_}not emphasized{_", contains: []string{"Emphasized\n_}not emphasized{_
"}}, {name: "example 7", input: "*not strong *strong*", contains: []string{"*not strong strong
"}}, {name: "example 8", input: "[My link text](http://example.com)", contains: []string{""}}, {name: "example 9", input: "[My link text](http://example.com?product_number=234234234234\n234234234234)", contains: []string{""}}, {name: "example 10", input: "[My link text][foo bar]\n\n[foo bar]: http://example.com", contains: []string{""}}, {name: "example 11", input: "[foo][bar]", contains: []string{""}}, {name: "example 12", input: "[My link text][]\n\n[My link text]: /url", contains: []string{""}}, {name: "example 13", input: "\n\n![picture of a cat][cat]\n\n![cat][]\n\n[cat]: feline.jpg", contains: []string{"


https://pandoc.org/lua-filters\nme@example.com
"}}, {name: "example 15", input: "``Verbatim with a backtick` character``\n`Verbatim with three backticks ``` character`", contains: []string{"Verbatim with a backtick` character\nVerbatim with three backticks ``` character
`foo`
foo bar
emphasized text
\nstrong emphasis
"}}, {name: "example 19", input: "_ Not emphasized (spaces). _\n\n___ (not an emphasized `_` character)", contains: []string{"_ Not emphasized (spaces). _
\n___ (not an emphasized _ character)
emphasis inside emphasis
"}}, {name: "example 21", input: "{_ this is emphasized, despite the spaces! _}", contains: []string{"this is emphasized, despite the spaces!
"}}, {name: "example 22", input: "This is {=highlighted text=}.", contains: []string{"This is highlighted text.
"}}, {name: "example 23", input: "H~2~O and djot^TM^", contains: []string{"H2O and djotTM
"}}, {name: "example 24", input: "H{~one two buckle my shoe~}O", contains: []string{"Hone two buckle my shoeO
"}}, {name: "example 25", input: "My boss is {-mean-}{+nice+}.", contains: []string{"My boss is meannice.
“Hello,” said the spider.\n“‘Shelob’ is my name.”
"}}, {name: "example 27", input: "'}Tis Socrates' season to be jolly!", contains: []string{"’Tis Socrates’ season to be jolly!
"}}, {name: "example 28", input: "5\\'11\\\"", contains: []string{"5'11\"
"}}, {name: "example 29", input: "57--33 oxen---and no sheep...", contains: []string{"57–33 oxen—and no sheep…
"}}, {name: "example 30", input: "a----b c------d", contains: []string{"a––b c——d
"}}, {name: "example 31", input: "Einstein derived $`e=mc^2`.\nPythagoras proved\n$$` x^n + y^n = z^n `", contains: []string{"Einstein derived \\(e=mc^2\\).\nPythagoras proved\n\\[ x^n + y^n = z^n \\]
"}}, {name: "example 32", input: "Here is the reference.[^foo]\n\n[^foo]: And here is the note.", contains: []string{"Here is the reference.1
\nAnd here is the note.↩︎︎
\nFoo bar baz.
"}}, {name: "example 36", input: "My reaction is :+1: :smiley:.", contains: []string{"My reaction is :+1: :smiley:.
"}}, {name: "example 37", input: "This is ``{=html}.", contains: []string{"This is .
"}}, {name: "example 38", input: "It can be helpful to [read the manual]{.big .red}.", contains: []string{"It can be helpful to read the manual.
"}}, {name: "example 39", input: "An attribute on _emphasized text_{#foo\n.bar .baz key=\"my value\"}", contains: []string{"An attribute on emphasized text
"}}, {name: "example 40", input: "avant{lang=fr}{.blue}", contains: []string{"avant
"}}, {name: "example 41", input: "avant{lang=fr .blue}", contains: []string{"avant
"}}, {name: "example 42", input: "## A level _two_ heading!", contains: []string{"A paragraph, finally
\nA paragraph, finally.
\n\n"}}, {name: "example 46", input: "> This is a block\nquote.", contains: []string{"This is a block quote.
\n\n
\n- \nwith a\n
\n- \nlist in it.\n
\n
\n"}}, {name: "example 47", input: "1. This is a\n list item.\n\n > containing a block quote", contains: []string{"This is a block\nquote.
\n
This is a\nlist item.
\n\n\ncontaining a block quote
\n
This is a\nlist item.
\nSecond paragraph under the\nlist item.
\nA citrus fruit.
\none
\ntwo
\nThis is how you do a code block:\n\n``` ruby\nx = 5 * 6\n```\n"}},
{name: "example 56", input: "> ```\n> code in a\n> block quote\n\nParagraph.", contains: []string{"\n\n\ncode in a\nblock quote\n
Paragraph.
"}}, {name: "example 57", input: "Then they went to sleep.\n\n * * * *\n\nWhen they woke up, ...", contains: []string{"Then they went to sleep.
\nWhen they woke up, …
"}}, {name: "example 58", input: "``` =html\n\n```", contains: []string{""}}, {name: "example 59", input: "::: warning\nHere is a paragraph.\n\nAnd here is another.\n:::", contains: []string{"Here is a paragraph.
\nAnd here is another.
\n| 1 | \n2 | \n
| fruit | \nprice | \n
|---|---|
| apple | \n4 | \n
| banana | \n10 | \n
| a | \nb | \n
|---|---|
| 1 | \n2 | \n
| 3 | \n4 | \n
just two | | | \ncells in this table | \n
Here’s the reference.1
\nThis is a note\nwith two paragraphs.
\nSecond paragraph.
\n\n\n\na block quote in the note.
\n
Here’s the reference.1
\nThis is a note\nwith two paragraphs.
\nSecond paragraph must\nbe indented, at least in the first line.↩︎︎
\nDon’t forget to turn off the water!
\n\n"}}, {name: "example 71", input: "## My heading + auto-identifier", contains: []string{"Sing, muse, of the wrath of Achilles
\n
See the Epilogue.
\n