-
Notifications
You must be signed in to change notification settings - Fork 118
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
Hyphen(-) issue #62
Comments
Hello @cainianhua, thanks for your report. I'm not sure I got your problem right. Can you describe it with some code examples please? For me the following looks like the expected behavior:
Don't you agree? |
Sorry for that, i lost a important condition, Hyphen(-) should be in the beginning, like that: ReverseMarkdown.convert('-test') #=> -test\n I expected the result should be <ul>
<li>test</li>
</ul> But I only want to show as original value, like that: -test Thanks for your helps. |
@cainianhua That sounds more like a problem of the markdown implementation you're using. In Redcarpet (a very common ruby implementation) the following works quite like expected: irb(main):004:0> Redcarpet::Markdown.new(Redcarpet::Render::HTML).render('-test')
=> "<p>-test</p>\n" |
Maybe you misunderstood my meanings, the codes you showed is making markdown to html. <div><p>-test</p></div> It displays the words of After called ReverseMarkdown.convert('<div><p>-test</p></div>') #=> -test\n\n It will display as list, like that: <ul>
<li>test</li>
</ul> Not the words of |
Hello @cainianhua I understand your example, but I think you're jumping to the wrong conclusion. Which markdown converter do you use to transform In Redcarpet (https://github.com/vmg/redcarpet) the result would be what you expected: I think the markdown converter you're using has a bug and shouldn't create a list from the given string. Do you agree with my analysis or am I missing something? |
Test string should be |
Hi @sdhull, please let me know what the expected result for the input you provided is. You won't be able to get the exact HTML that you provided in a full round trip though. The So from my point of view this conversion looks OK: ReverseMarkdown.convert "<div><p>- test</p></div>"
=> "- test\n\n" If the HTML contains markdown formatted content, like in this example the list item, this content will inevitably be transformed at some point. md.render "\- foobar" # use redcarpet
=> "<ul>\n<li>foobar</li>\n</ul>\n" |
Ohhh I see. Well in that case, I'd suggest closing this issue. It might be worth adding a "Limitations" section to the readme pointing out that if the HTML you're converting to markdown has markdown-formatted text (text that would be interpreted by markdown parsers as lists, headers, hr's, etc), then a "roundtrip" (eg converting from html to markdown back to html) will inevitably produce a different result than what you started with. On a somewhat related tangential note, I'd love to be able to turn off escaping of node text altogether (considering it only escapes |
@sdhull Sounds good, I'd be happy to merge any PR to improve documentation. |
Hyphen(-) in markdown should be show as a list, i think we should escape hyphen(-) to "-", otherwise after converted, hyphen(-) will be show as a list, but i expected only a normal hyphen(-), not list.
The text was updated successfully, but these errors were encountered: