Skip to content

Commit 69f74f7

Browse files
committed
feat: adding [code] to simple parser which compiles to a pre-tag
1 parent 3498114 commit 69f74f7

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Diff for: src/simple.js

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default new BBCode({
1515
'\\[h6\\](.+?)\\[/h6\\]': '<h6>$1</h6>',
1616

1717
'\\[p\\](.+?)\\[/p\\]': '<p>$1</p>',
18+
'\\[code\\](.+?)\\[/code\\]': '<pre>$1</pre>',
1819

1920
'\\[color=(.+?)\\](.+?)\\[/color\\]': '<span style="color:$1">$2</span>',
2021
'\\[size=([0-9]+)\\](.+?)\\[/size\\]': '<span style="font-size:$1px">$2</span>',

Diff for: test/simple.test.js

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ describe('Default Parser', () => {
77
'[list]\n[*]item 1[/*]\n[*]item 2[/*]\n[/list]\n\n[b]\nmulti line\nbold text\n[/b]',
88
'<ul>\n<li>item 1</li>\n<li>item 2</li>\n</ul>\n\n<strong>\nmulti line\nbold text\n</strong>',
99
],
10+
[ // #20 https://github.com/DasRed/js-bbcode-parser/issues/20
11+
'[code]nuff nuff nuff[/code] rofl copter [p]lalalaalalal[/p]',
12+
'<pre>nuff nuff nuff</pre> rofl copter <p>lalalaalalal</p>',
13+
],
1014
].forEach(
1115
([input, output], index) => it(`#${index} parsing input to the correct output`,
1216
() => assert.strict.equal(bbCodeParser.parse(input), output)

0 commit comments

Comments
 (0)