kadikraman / draftjs-md-converter

Converts content from Draft.js blocks to Markdown and vice versa.
https://kadikraman.github.io/draftjs-md-converter/
MIT License
145 stars 37 forks source link

Styles depend on inlineStyleRanges order #28

Closed aliwoodman closed 6 years ago

aliwoodman commented 6 years ago

Hi,

I'm so happy this exists and has easy to follow tests!

It does most of what we need, but we have found that inline styles only work as expected when they're added in a certain order.

When the length of the inlineStyleRange of the first element is shorter than the second, we get unexpected markdown.

We reference the given blocks in a PR to resolve this, but the short of it is:

Expected: __*I start with italic bold* and end with only bold.__ Actual: *__I start with italic bold and end with only bold.__

So, the "closing markdown" for the first inlineStyleRange is stripped, as it would end inside the second inlineStyleRange which is longer despite being second.