1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-13 05:50:27 +00:00

Strike-through tag

This commit is contained in:
bouncepaw 2020-11-11 22:42:31 +05:00
parent 88bf3c3d3a
commit 8bc3fb9821
3 changed files with 9 additions and 2 deletions

View File

@ -41,7 +41,7 @@ func TestLex(t *testing.T) {
</ul>`}, </ul>`},
{6, "<p id='6'>text</p>"}, {6, "<p id='6'>text</p>"},
{7, "<p id='7'>more text</p>"}, {7, "<p id='7'>more text</p>"},
{8, `<p><a id='8' class='rocketlink wikilink_internal' href="/page/Pear">some link</a></p>`}, {8, `<p><a id='8' class='rocketlink wikilink_internal' href="/page/pear">some link</a></p>`},
{9, `<ul id='9'> {9, `<ul id='9'>
<li>lin&#34;+</li> <li>lin&#34;+</li>
</ul>`}, </ul>`},

View File

@ -17,6 +17,7 @@ const (
spanSuper spanSuper
spanSub spanSub
spanMark spanMark
spanStrike
spanLink spanLink
) )
@ -78,7 +79,7 @@ func getTextNode(input *bytes.Buffer) string {
escaping = false escaping = false
} else if b == '\\' { } else if b == '\\' {
escaping = true escaping = true
} else if strings.IndexByte("/*`^,![", b) >= 0 { } else if strings.IndexByte("/*`^,![~", b) >= 0 {
input.UnreadByte() input.UnreadByte()
break break
} else { } else {
@ -127,6 +128,9 @@ func ParagraphToHtml(hyphaName, input string) string {
case startsWith("!!"): case startsWith("!!"):
ret.WriteString(tagFromState(spanMark, tagState, "mark", "!!")) ret.WriteString(tagFromState(spanMark, tagState, "mark", "!!"))
p.Next(2) p.Next(2)
case startsWith("~~"):
ret.WriteString(tagFromState(spanMark, tagState, "s", "~~"))
p.Next(2)
case startsWith("[["): case startsWith("[["):
ret.WriteString(getLinkNode(p, hyphaName)) ret.WriteString(getLinkNode(p, hyphaName))
default: default:
@ -149,6 +153,8 @@ func ParagraphToHtml(hyphaName, input string) string {
ret.WriteString(tagFromState(spanSub, tagState, "sub", ",,")) ret.WriteString(tagFromState(spanSub, tagState, "sub", ",,"))
case spanMark: case spanMark:
ret.WriteString(tagFromState(spanMark, tagState, "mark", "!!")) ret.WriteString(tagFromState(spanMark, tagState, "mark", "!!"))
case spanStrike:
ret.WriteString(tagFromState(spanMark, tagState, "s", "~~"))
case spanLink: case spanLink:
ret.WriteString(tagFromState(spanLink, tagState, "a", "[[")) ret.WriteString(tagFromState(spanLink, tagState, "a", "[["))
} }

View File

@ -32,6 +32,7 @@ func TestParagraphToHtml(t *testing.T) {
{"Embedded //italic//", "Embedded <em>italic</em>"}, {"Embedded //italic//", "Embedded <em>italic</em>"},
{"double //italian// //text//", "double <em>italian</em> <em>text</em>"}, {"double //italian// //text//", "double <em>italian</em> <em>text</em>"},
{"it has `mono`", "it has <code>mono</code>"}, {"it has `mono`", "it has <code>mono</code>"},
{"it has ~~strike~~", "it has <s>strike</s>"},
{"this is a left **bold", "this is a left <strong>bold</strong>"}, {"this is a left **bold", "this is a left <strong>bold</strong>"},
{"this line has a ,comma, two of them", "this line has a ,comma, two of them"}, {"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."}, {"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."},