Skip to content

Commit 6b161bc

Browse files
author
Pasha Rumkin
committed
fix xibbling plugins without blocks
* Fix rule processing in code @jHoldroyd * Add example * Rewrite tests from ECMA2017 to ECMA 5
1 parent baa1c1c commit 6b161bc

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

lib/marked.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ Lexer.prototype.token = function(src, top, bq) {
201201
type: 'plugin',
202202
plugin: cap[1],
203203
params: cap[3],
204-
block: cap[4].replace(new RegExp('^' + cap[4].match(/^\s+/)[0], 'gm'), ''),
204+
block: cap[4] !== undefined ? cap[4].replace(new RegExp('^' + cap[4].match(/^\s+/)[0], 'gm'), '') : undefined,
205205
});
206206
continue;
207207
}

test/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,12 @@ function runTests(engine, options) {
8787
var renderer = new marked.Renderer();
8888
renderer.plugins = {};
8989
renderer.plugins.github = function(params, body) {
90-
return `<a href="https://github.com/${body}">${body}</a>`;
90+
return '<a href="https://github.com/' + body + '">' + body + '</a>';
91+
};
92+
93+
renderer.plugins.link = function(params, body) {
94+
var parts = params.split(/\s*,\s*/);
95+
return '<a href="' + parts[1] + '">' + parts[0] + '</a>';
9196
};
9297

9398
main:

test/tests/plugin_github.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
<a href="https://github.com">github</a>
12
<a href="https://github.com/chjj/marked">chjj/marked</a>

test/tests/plugin_github.text

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@link(github, https://github.com)
12
@github(https)
23
chjj/marked
34

0 commit comments

Comments
 (0)