Skip to content

Commit

Permalink
fixed renderer for bold and italic bracket tags (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxlath authored and claudioc committed Jan 8, 2017
1 parent 1a60663 commit cd3780a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var tagmap = {}
function extractTags (text) {
tagmap = {}

var matches = text.match(/(.?)\[\[(.+?)\]\]/g)
var matches = text.match(/\[\[(.+?)\]\]/g)
var tag
var id

Expand Down
15 changes: 15 additions & 0 deletions test/spec/rendererSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ describe('Renderer', function () {
expect(Renderer.render(text)).to.be.equal('<p><a class="internal" href="/wiki/Foo">Foo</a>, <a class="internal" href="/wiki/Bar">Bar</a></p>\n')
})

it('should render bold bracket tags', function () {
var text = 'foo **[[Bar]]** buzz'
expect(Renderer.render(text)).to.be.equal('<p>foo <strong><a class="internal" href="/wiki/Bar">Bar</a></strong> buzz</p>\n')
})

it('should render italic bracket tags', function () {
var text = 'foo *[[Bar]]* buzz'
expect(Renderer.render(text)).to.be.equal('<p>foo <em><a class="internal" href="/wiki/Bar">Bar</a></em> buzz</p>\n')
})

it('should render italic bold bracket tags', function () {
var text = 'foo ***[[Bar]]*** buzz'
expect(Renderer.render(text)).to.be.equal('<p>foo <strong><em><a class="internal" href="/wiki/Bar">Bar</a></em></strong> buzz</p>\n')
})

it('should replace {{TOC}} with the table of contents', function () {
var text = '{{TOC}}\n\n # Heading 1 \n\n This is some text'
expect(Renderer.render(text)).to.be.equal('<ul>\n<li><p><a href="#heading-1">Heading 1</a></p>\n<h1 id="heading-1">Heading 1</h1>\n<p>This is some text</p>\n</li>\n</ul>\n')
Expand Down

0 comments on commit cd3780a

Please sign in to comment.