Browse Source

Fixed sub-sup tokens format. Closes #21

pull/24/head
Vitaly Puzrin 10 years ago
parent
commit
814f85af96
  1. 2
      Makefile
  2. 14
      lib/renderer.js
  3. 4
      lib/rules_inline/sub.js
  4. 4
      lib/rules_inline/sup.js

2
Makefile

@ -106,5 +106,5 @@ todo:
grep 'TODO' -n -r ./lib 2>/dev/null || test true
.PHONY: publish lint test gh-pages todo demo coverage doc
.PHONY: publish lint test todo demo coverage doc
.SILENT: help lint test todo

14
lib/renderer.js

@ -242,11 +242,17 @@ rules.mark_close = function (/* tokens, idx, options, env */) {
};
rules.sub = function (tokens, idx /*, options, env */) {
return '<sub>' + escapeHtml(tokens[idx].content) + '</sub>';
rules.sub_open = function (/*tokens, idx, options, env */) {
return '<sub>';
};
rules.sup = function (tokens, idx /*, options, env */) {
return '<sup>' + escapeHtml(tokens[idx].content) + '</sup>';
rules.sub_close = function (/*tokens, idx, options, env */) {
return '</sub>';
};
rules.sup_open = function (/*tokens, idx, options, env */) {
return '<sup>';
};
rules.sup_close = function (/*tokens, idx, options, env */) {
return '</sup>';
};

4
lib/rules_inline/sub.js

@ -45,11 +45,13 @@ module.exports = function sub(state, silent) {
state.pos = start + 1;
if (!silent) {
state.push({ type: 'sub_open', level: state.level++ });
state.push({
type: 'sub',
type: 'text',
level: state.level,
content: content.replace(UNESCAPE_RE, '$1')
});
state.push({ type: 'sub_close', level: --state.level });
}
state.pos = state.posMax + 1;

4
lib/rules_inline/sup.js

@ -45,11 +45,13 @@ module.exports = function sup(state, silent) {
state.pos = start + 1;
if (!silent) {
state.push({ type: 'sup_open', level: state.level++ });
state.push({
type: 'sup',
type: 'text',
level: state.level,
content: content.replace(UNESCAPE_RE, '$1')
});
state.push({ type: 'sup_close', level: --state.level });
}
state.pos = state.posMax + 1;

Loading…
Cancel
Save