Skip to content

Commit

Permalink
Update plugin to work with [email protected]
Browse files Browse the repository at this point in the history
  • Loading branch information
rlidwka committed Mar 6, 2015
1 parent 712bc24 commit be9e92a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
22 changes: 9 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var UNESCAPE_RE = /\\([ \\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;
function superscript(state, silent) {
var found,
content,
token,
max = state.posMax,
start = state.pos;

Expand Down Expand Up @@ -44,26 +45,21 @@ function superscript(state, silent) {
state.pos = start + 1;

// Earlier we checked !silent, but this implementation does not need it
state.push({ type: 'sup_open', level: state.level++ });
state.push({
type: 'text',
level: state.level,
content: content.replace(UNESCAPE_RE, '$1')
});
state.push({ type: 'sup_close', level: --state.level });
token = state.push('sup_open', 'sup', 1);
token.markup = '^';

token = state.push('text', '', 0);
token.content = content.replace(UNESCAPE_RE, '$1');

token = state.push('sup_close', 'sup', -1);
token.markup = '^';

state.pos = state.posMax + 1;
state.posMax = max;
return true;
}


function sup_open() { return '<sup>'; }
function sup_close() { return '</sup>'; }


module.exports = function sup_plugin(md) {
md.inline.ruler.after('emphasis', 'sup', superscript);
md.renderer.rules.sup_open = sup_open;
md.renderer.rules.sup_close = sup_close;
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"eslint-plugin-nodeca": "^1.0.0",
"istanbul": "*",
"lodash": "*",
"markdown-it": "~3.0.0",
"markdown-it": "git+https://github.com/markdown-it/markdown-it.git#dev",
"markdown-it-testgen": "~0.1.0",
"mocha": "*",
"request": "*",
Expand Down

0 comments on commit be9e92a

Please sign in to comment.