React-markdown: Support for <sub>

Created on 25 Feb 2016  路  9Comments  路  Source: remarkjs/react-markdown

Hi is there any plans to support superscript in this markdown parser? I tried using <sub>1</sub> but this tag gets converted to even if I specify skipHTML option.

馃悰 typbug

Most helpful comment

+1 As I need support for <sup>

All 9 comments

Commonmark doesn't specify any type for it, but html should be supported. I suspect the sloppy inline html parsing is causing this, but can't check right now. What does it get converted to?

Sorry I missed that in the original issue. It is converting sub to span

Hrm, yeah. I really have to get the inline HTML handling fixed. No solution for this right now, unfortunately.

+1 As I need support for <sup>

I tracked this down to this line;

https://github.com/rexxars/commonmark-react-renderer/blob/master/src/commonmark-react-renderer.js#L89

It seems that all HtmlBlock and HtmlInline node types are either rendered as <div> or <span> regardless of what the original HTML was.

@rexxars Could you do a regex on props.literal to determine what kind of tag it is? Seems like props.literal.match(/[A-Z]+/i)[0] could work. Or something like props.literal.match(/^<(sup|sub|span)>$/i)[1]. I'll open a PR on commonmark-react-renderer.

Oh, actually, this is related to https://github.com/rexxars/commonmark-react-renderer/issues/9

I'll continue discussion there.

The new release candidate for v3 has (very basic) support for attributeless, inline html nodes. Please read this issue for more information. Please give it a go and let me know if you encounter issues.

@rexxars Coming into this in 2020, I don't see an easy way of using the tag other than enabling "allowDangerousHtml". Any clues here?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joelin109 picture joelin109  路  3Comments

IonicaBizau picture IonicaBizau  路  4Comments

zhenyulin picture zhenyulin  路  3Comments

pcvandamcb picture pcvandamcb  路  3Comments

wqh17101 picture wqh17101  路  3Comments