Skip to content

[BUG] StrikeThroughSupSubToggles should support pandoc-style sup/sub #829

@firxworx

Description

@firxworx

Describe the bug

This is sort of a combined bug / feature request. It is a bug in the sense that the package did not do what the user (developer) expected.

StrikeThroughSupSubToggles should support common markdown syntax for superscript and subscript as are commonly found in science/math and in technical documentation.

The current behaviour outputs HTML sup and sup elements however this is incompatible with many Markdown/MDX configurations especially those that adopt the common practice of sanitizing all HTML.

I think the current behaviour should continue to be supported however I propose an additional prop/option be added for the developer to choose their preference for HTML or markdown output.

Proposed Pandoc Syntax Support

The Pandoc style is very common to represent superscript and subscript in Markdown e.g.

m^2^ 
E=mc^2^
CO~2~

Per Pandoc spec:

if the superscripted or subscripted text contains spaces, these spaces must be escaped with backslashes. (This is to prevent accidental superscripting and subscripting through the ordinary use of ~ and ^.) Thus, if you want the letter P with ‘a cat’ in subscripts, use Pa\ cat, not Pa cat.

Reproduction

I don't think a repro is necessary to communicate the issue.

To Reproduce

Define toolbarPlugin with toolbarContents that includes:

<StrikeThroughSupSubToggles options={['Sub', 'Sup']} />

Use the editor and add superscript/subscript. Note the raw markdown/mdx generated uses HTML sup and sup tags and there is no option to support the more idiomatic / expected syntax used by the community to represent superscript and subscript.

Expected behavior

I expect that the official plugin and toolbar for Sup/Sub would at least provide an option for pandoc sup/sub over HTML.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions