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

Bug with code block #36

Closed andrewfan closed 5 years ago

andrewfan commented 6 years ago

Hey, I have a value

  some text
   \```
   some code 
   \```

and draftjsToMd returns everything wrapped in ```

i think it happens here https://github.com/kadikraman/draftjs-md-converter/blob/master/src/draftjsToMd.js#L180

For now i fixed it with

   let newString += block.text.split... 
   ....
   newString = applyWrappingBlockStyle(block.type, newString);
   newString = applyAtomicStyle(block, raw.entityMap, newString);
   returnString += newString;
kadikraman commented 6 years ago

Hi @andrewfan so sorry, I don't know how I missed this issue! I'd love to fix it, but I can't seem to write a test to replicate it. Am I understanding correctly that inputting

some text
\```
some code 
\```

will return the equivalent of this when rendered in draft.js?

\```
some text
some code 
\```
insaindesign commented 5 years ago

Created https://github.com/kadikraman/draftjs-md-converter/pull/49 with test case and fix