TarekkMA / markdown_quill

Convert quill (Delta) fromat to and from markdown
MIT License
18 stars 41 forks source link

Delta to markdown format wrong. #3

Open chifandeyu opened 2 years ago

chifandeyu commented 2 years ago
final convertedValue = '[{"insert":"1"},{"insert":"2","attributes":{"italic":true}},{"insert":"3","attributes":{"italic":true,"bold":true}},{"insert":"4","attributes":{"bold":true}},{"insert":"\n"}]';
final markdown = DeltaToMarkdown().convert(delta);

but result markdown is '1_2**3_4**\n\n'. The format is wrong.

TarekkMA commented 2 years ago

Thank you for reporting an issue.

Hmmm, what do you think the expected output be?

chifandeyu commented 2 years ago

Can it be represented by HTML tags? example: result is "1\2\\**3**\**4**\n";

TarekkMA commented 2 years ago

I think we would want a pure markdown, not HTML.

danhunsaker commented 1 year ago

Overlapping formatting marks are parsed a bit inconsistently by markdown parsers, mostly because HTML doesn't support them. But also because some parsers ignore inline underscores since they're so common in things like filenames.

GFM, for example, needs things to be the more explicit 1*2*_**3**_**4**\n\n to get '1234\n\n' (see here). You could add spaces to simplify this, as in 1 _2_ **_3_ 4** to get 1 2 3 4, but still have to nest rather than overlap the markers.

The fact that even HTML doesn't support 1<em>2<strong>3</em>4</strong> means markdown generally won't either.