remarkable icon indicating copy to clipboard operation
remarkable copied to clipboard

Subscript and Superscript implementation

Open Dagur opened this issue 5 years ago • 0 comments

I'm wondering why subscript and superscript are implemented differently than for example bold and italic in rules.js

What I mean is that bold has strong_open and strong_close like this

rules.strong_open = function(/* tokens, idx, options, env */) {
  return '<strong>';
};
rules.strong_close = function(/* tokens, idx, options, env */) {
  return '</strong>';
};

but super/subscript is like this

rules.sub = function(tokens, idx /*, options, env */) {
  return '<sub>' + escapeHtml(tokens[idx].content) + '</sub>';
};

so the whole thing, including content, is one token.

This means that text inside sub and sup that has other formatting is not dealt with. Wouldn't it be better if it was treated the same way as bold and italic?

Dagur avatar Jun 25 '20 10:06 Dagur