Rosey / markdown-draft-js

A tool to convert content created in DraftJS to markdown and vice versa.
https://rosey.github.io/markdown-draft-js/
MIT License
318 stars 69 forks source link

Two spaces and a new-line in Markdown doesn't translate into a new-line in draft-js #87

Closed tilds closed 5 years ago

tilds commented 5 years ago

Hi, I was checking out the demo: http://www.roserobertson.me/markdown-draft-js/ and noticed that if I end a line in the markdown with two spaces and a new-line then the next line is just appended on to the first in the draft-js. This is intended? image

Rosey commented 5 years ago

Hmm yeah I think that is a bug, nice catch 👍 / 😢

tilds commented 5 years ago

I looked at it a bit more and the problem seems to be that 'hardbreak' is not handled in markdown-to-draft.parseInline()

Looking at the debug mode of the remarkable demo: https://jonschlinkert.github.io/remarkable/demo/ I get this:


  {
    "type": "paragraph_open",
    "tight": false,
    "lines": [
      0,
      2
    ],
    "level": 0
  },
  {
    "type": "inline",
    "content": "First line  \nSecond line",
    "level": 1,
    "lines": [
      0,
      2
    ],
    "children": [
      {
        "type": "text",
        "content": "First line",
        "level": 0
      },
      {
        "type": "hardbreak",
        "level": 0
      },
      {
        "type": "text",
        "content": "Second line",
        "level": 0
      }
    ]
  },
  {
    "type": "paragraph_close",
    "tight": false,
    "level": 0
  }
]
Rosey commented 5 years ago

ahh, very nice. OK I'm a bit busy these days but I'll try to get to this, or if anyone else who is reading this issue and has the inclination they are welcome to take it on!

Rosey commented 5 years ago

Thanks to @kamilbielawski a fix for this has been released under 1.4.0

Rosey commented 5 years ago

(and thanks @tilds for your detailed comment about what the issue was too 😄)