From 879b4abde722cb66463ca81a4cf6ac5465ef276d Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Sun, 7 Aug 2022 18:19:16 +0200 Subject: [bugfix] Markdown formatting updates (#743) * add minify dependency specifically for markdown * rearrange markdown formatting * update markdown tests --- internal/text/markdown_test.go | 43 +++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) (limited to 'internal/text/markdown_test.go') diff --git a/internal/text/markdown_test.go b/internal/text/markdown_test.go index 74a18a685..af4a4fef6 100644 --- a/internal/text/markdown_test.go +++ b/internal/text/markdown_test.go @@ -44,19 +44,23 @@ that was some JSON :) ` const ( - simpleMarkdown = "# Title\n\nHere's a simple text in markdown.\n\nHere's a [link](https://example.org)." - simpleMarkdownExpected = "
Here’s a simple text in markdown.
\n\nHere’s a link.
\n" - withCodeBlockExpected = "Below is some JSON.
\n\n{\n "key": "value",\n "another_key": [\n "value1",\n "value2"\n ]\n}\n
\n\nthat was some JSON :)
\n" - withInlineCode = "`Nobody tells you about theSECRET CODE
, do they?`"
- withInlineCodeExpected = "Nobody tells you about the <code><del>SECRET CODE</del></code>, do they?
, do they?`"
- withInlineCode2Expected = "Nobody tells you about the </code><del>SECRET CODE</del><code>, do they?
\n"
- withHashtag = "# Title\n\nhere's a simple status that uses hashtag #Hashtag!"
- withHashtagExpected = "Title
\n\nhere’s a simple status that uses hashtag #Hashtag!
\n"
- mdWithHTML = "# Title\n\nHere's a simple text in markdown.\n\nHere's a link.\n\nHere's an image:
"
- mdWithHTMLExpected = "Title
\n\nHere’s a simple text in markdown.
\n\nHere’s a link.
\n\nHere’s an image: 
\n"
- mdWithCheekyHTML = "# Title\n\nHere's a simple text in markdown.\n\nHere's a cheeky little script: "
- mdWithCheekyHTMLExpected = "Title
\n\nHere’s a simple text in markdown.
\n\nHere’s a cheeky little script:
\n"
+ simpleMarkdown = "# Title\n\nHere's a simple text in markdown.\n\nHere's a [link](https://example.org)."
+ simpleMarkdownExpected = "Title
Here’s a simple text in markdown.
Here’s a link.
"
+ withCodeBlockExpected = "Title
Below is some JSON.
{\n "key": "value",\n "another_key": [\n "value1",\n "value2"\n ]\n}\n
that was some JSON :)
"
+ withInlineCode = "`Nobody tells you about the SECRET CODE
, do they?`"
+ withInlineCodeExpected = "Nobody tells you about the <code><del>SECRET CODE</del></code>, do they?
"
+ withInlineCode2 = "`Nobody tells you about the
, do they?`"
+ withInlineCode2Expected = "Nobody tells you about the </code><del>SECRET CODE</del><code>, do they?
"
+ withHashtag = "# Title\n\nhere's a simple status that uses hashtag #Hashtag!"
+ withHashtagExpected = "Title
here’s a simple status that uses hashtag #Hashtag!
"
+ mdWithHTML = "# Title\n\nHere's a simple text in markdown.\n\nHere's a link.\n\nHere's an image:
"
+ mdWithHTMLExpected = "Title
Here’s a simple text in markdown.
Here’s a link.
Here’s an image: 
"
+ mdWithCheekyHTML = "# Title\n\nHere's a simple text in markdown.\n\nHere's a cheeky little script: "
+ mdWithCheekyHTMLExpected = "Title
Here’s a simple text in markdown.
Here’s a cheeky little script:
"
+ mdWithHashtagInitial = "#welcome #Hashtag"
+ mdWithHashtagInitialExpected = ""
+ mdCodeBlockWithNewlines = "some code coming up\n\n```\n\n\n\n```\nthat was some code"
+ mdCodeBlockWithNewlinesExpected = "some code coming up
\n\n\n
that was some code
"
)
type MarkdownTestSuite struct {
@@ -102,6 +106,19 @@ func (suite *MarkdownTestSuite) TestParseWithCheekyHTML() {
suite.Equal(mdWithCheekyHTMLExpected, s)
}
+func (suite *MarkdownTestSuite) TestParseWithHashtagInitial() {
+ s := suite.formatter.FromMarkdown(context.Background(), mdWithHashtagInitial, nil, []*gtsmodel.Tag{
+ suite.testTags["Hashtag"],
+ suite.testTags["welcome"],
+ })
+ suite.Equal(mdWithHashtagInitialExpected, s)
+}
+
+func (suite *MarkdownTestSuite) TestParseCodeBlockWithNewlines() {
+ s := suite.formatter.FromMarkdown(context.Background(), mdCodeBlockWithNewlines, nil, nil)
+ suite.Equal(mdCodeBlockWithNewlinesExpected, s)
+}
+
func TestMarkdownTestSuite(t *testing.T) {
suite.Run(t, new(MarkdownTestSuite))
}
--
cgit v1.2.3