Skip to content

Commit

Permalink
update handling of inlined elements and added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chaseadamsio committed Feb 22, 2017
1 parent 5123bf7 commit f560ba4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 5 additions & 3 deletions goorgeous.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,11 @@ func findLastCharInInline(data []byte, char byte) int {
if timesFound == 1 {
break
}
if data[i] == char && (len(data) > i+1 && isAcceptablePostClosingChar(data[i+1])) {
last = i
timesFound += 1
if data[i] == char {
if len(data) == i+1 || (len(data) > i+1 && isAcceptablePostClosingChar(data[i+1])) {
last = i
timesFound += 1
}
}
}
return last
Expand Down
8 changes: 8 additions & 0 deletions goorgeous_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ func TestRenderingInline(t *testing.T) {
"this is ==inline code==.\n",
"<p>this is <code>=inline code=</code>.</p>\n",
},
"verbatim-no-surrounding-text": {
"==Verbatim==\n",
"<p><code>=Verbatim=</code></p>\n",
},
"code": {
"this has ~code~.\n",
"<p>this has <code>code</code>.</p>\n",
Expand Down Expand Up @@ -408,6 +412,10 @@ func TestRenderingTables(t *testing.T) {
"|---+---+---|\n| d | e | f |\n|---+---+---|\n| g | h | i |\n|---+---+---|\n",
"\n<table>\n<tbody>\n<tr>\n<td>d</td>\n<td>e</td>\n<td>f</td>\n</tr>\n\n<tr>\n<td>g</td>\n<td>h</td>\n<td>i</td>\n</tr>\n</tbody>\n</table>\n",
},
"table-with-inlined-elements": {
"| Format | Org mode markup syntax |\n| *Bold* | =*Bold*= |\n| /Italics/ | =/Italics/= |\n| _Underline_ | =_Underline_= |\n| =Verbatim= | ==Verbatim== |\n| +Strike-through+ | =+Strike-through+= |\n",
"\n<table>\n<tbody>\n<tr>\n<td>Format</td>\n<td>Org mode markup syntax</td>\n</tr>\n\n<tr>\n<td><strong>Bold</strong></td>\n<td><code>*Bold*</code></td>\n</tr>\n\n<tr>\n<td><em>Italics</em></td>\n<td><code>/Italics/</code></td>\n</tr>\n\n<tr>\n<td><span style=\"text-decoration: underline;\">Underline</span></td>\n<td><code>_Underline_</code></td>\n</tr>\n\n<tr>\n<td><code>Verbatim</code></td>\n<td><code>=Verbatim=</code></td>\n</tr>\n\n<tr>\n<td><del>Strike-through</del></td>\n<td><code>+Strike-through+</code></td>\n</tr>\n</tbody>\n</table>\n",
},
}

testOrgCommon(testCases, t)
Expand Down

0 comments on commit f560ba4

Please sign in to comment.