Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up superscript/subscript markup #35

Open
Mr0grog opened this issue Apr 18, 2022 · 0 comments
Open

Clean up superscript/subscript markup #35

Mr0grog opened this issue Apr 18, 2022 · 0 comments
Labels
enhancement New feature or request output formatting

Comments

@Mr0grog
Copy link
Owner

Mr0grog commented Apr 18, 2022

In #34, I added superscript and subscript support. However, the output is often messier than need be because Google Docs nests the superscript/subscript formatting inside other inline formatting (like bold or italics), so formatting inside the superscript/subscript can break things up into several sup or sub tags.

For example, Google Docs might produce input like the following if only part of a subscript was bold:

<span style="vertical-align: sub;">
  Plain text
</span>
<span style="font-weight: bold;">
  <span style="vertical-align: sub;">
    bold text
  </span>
</span>

Which produces markdown output like:

<sub>Plain text </sub>**<sub>bold text</sub>**

It would probably be nicer to go the other way around and treat the subscript/superscript as the outer layer of nesting if it’s the only thing inside the italic/bold. So we’d wrangle the GDocs HTML from above into something like:

<span style="vertical-align: sub;">
  Plain text
</span>
<span style="vertical-align: sub;">
  <span style="font-weight: bold;">
    bold text
  </span>
</span>

And then merge consecutive <sub> or <sup> elements to ultimately get output like:

<sub>Plain text **bold text**</sub>
@Mr0grog Mr0grog added the enhancement New feature or request label Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request output formatting
Projects
None yet
Development

No branches or pull requests

1 participant