From cc3cc10ef203025e34a5b71fd060b1ea7d6cd8db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vytautas=20=C5=A0altenis?= Date: Mon, 12 Oct 2015 21:06:27 +0300 Subject: [PATCH] Fix bug parsing emphasis Start searching for emphasis character at 0th index instead of 1st. Fixes a corner case with doubly emphasised code span followed by another code span on the same line. Changes interpretation of improperly nested emphasis, hence the change in TestEmphasisMix(). Closes #156. --- inline.go | 2 +- inline_test.go | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/inline.go b/inline.go index 3f39b52..d9ad3aa 100644 --- a/inline.go +++ b/inline.go @@ -910,7 +910,7 @@ func isMailtoAutoLink(data []byte) int { // look for the next emph char, skipping other constructs func helperFindEmphChar(data []byte, c byte) int { - i := 1 + i := 0 for i < len(data) { for i < len(data) && data[i] != c && data[i] != '`' && data[i] != '[' { diff --git a/inline_test.go b/inline_test.go index 3821d49..82b470a 100644 --- a/inline_test.go +++ b/inline_test.go @@ -263,6 +263,12 @@ func TestStrong(t *testing.T) { "mix of **markers__\n", "

mix of **markers__

\n", + + "**`/usr`** : this folder is named `usr`\n", + "

/usr : this folder is named usr

\n", + + "**`/usr`** :\n\n this folder is named `usr`\n", + "

/usr :

\n\n

this folder is named usr

\n", } doTestsInline(t, tests) } @@ -291,7 +297,7 @@ func TestEmphasisMix(t *testing.T) { "

improper *nesting is* bad

\n", "*improper **nesting* is** bad\n", - "

improper **nesting is** bad

\n", + "

*improper nesting* is bad

\n", } doTestsInline(t, tests) }