Skip to content

Commit

Permalink
Code beginning with a dot is not rendered as code (#59)
Browse files Browse the repository at this point in the history
* Since dot is considered as terminating character finding the dot after the
beginning of the inline indicator terminates the inline. So starting from the
character after the beginning of inline indicator.

* Making the name consistent across all the tests
  • Loading branch information
ageekymonk authored and chaseadamsio committed Aug 31, 2017
1 parent 16f2007 commit a3688bd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion goorgeous.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,8 @@ func isTerminatingChar(char byte) bool {
func findLastCharInInline(data []byte, char byte) int {
timesFound := 0
last := 0
for i := 0; i < len(data); i++ {
// Start from character after the inline indicator
for i := 1; i < len(data); i++ {
if timesFound == 1 {
break
}
Expand Down
20 changes: 20 additions & 0 deletions goorgeous_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ func TestRenderingInline(t *testing.T) {
"this string /has emphasis text/.\n",
"<p>this string <em>has emphasis text</em>.</p>\n",
},
"emphasis-with-dot-at-front": {
"this string /.has emphasis text/.\n",
"<p>this string <em>.has emphasis text</em>.</p>\n",
},
"emphasis-with-slash-inside": {
"this string /has a slash/inside and emphasis text/.\n",
"<p>this string <em>has a slash/inside and emphasis text</em>.</p>\n",
Expand Down Expand Up @@ -280,6 +284,10 @@ func TestRenderingInline(t *testing.T) {
"this string *has bold text*.\n",
"<p>this string <strong>has bold text</strong>.</p>\n",
},
"bold-with-dot-at-front": {
"this string *.has bold text*.\n",
"<p>this string <strong>.has bold text</strong>.</p>\n",
},
"bold-with-asterisk-inside": {
"this string *has *asterisk and bold text*.\n",
"<p>this string <strong>has *asterisk and bold text</strong>.</p>\n",
Expand All @@ -304,10 +312,18 @@ func TestRenderingInline(t *testing.T) {
"this is _underlined text_.\n",
"<p>this is <span style=\"text-decoration: underline;\">underlined text</span>.</p>\n",
},
"underline-with-dot-at-front": {
"this is _.underlined text_.\n",
"<p>this is <span style=\"text-decoration: underline;\">.underlined text</span>.</p>\n",
},
"verbatim": {
"this is =inline code=.\n",
"<p>this is <code>inline code</code>.</p>\n",
},
"verbatim-with-dot-at-front": {
"this is =.inline code=.\n",
"<p>this is <code>.inline code</code>.</p>\n",
},
"verbatim-with-equal-in-code": {
"this is =inline=code=.\n",
"<p>this is <code>inline=code</code>.</p>\n",
Expand All @@ -332,6 +348,10 @@ func TestRenderingInline(t *testing.T) {
"this has ~code~.\n",
"<p>this has <code>code</code>.</p>\n",
},
"code-with-dot-at-front": {
"this has ~.code~.\n",
"<p>this has <code>.code</code>.</p>\n",
},
"code-not": {
"this has not~code~.\n",
"<p>this has not~code~.</p>\n",
Expand Down

0 comments on commit a3688bd

Please sign in to comment.