leeoniya / reMarked.js

client-side HTML > markdown
http://leeoniya.github.io/reMarked.js/
396 stars 97 forks source link

Li tags converted to code tag equivalent #37

Closed jatin0502 closed 10 years ago

jatin0502 commented 10 years ago

Steps to Reproduce: Add a formatted line text. press enter Add two numbered lists with bold italic alternate formattings.

Issue: When the above is remarked it is seen that four whitespaces or a tab is inserted prior to the number. Hence when marked up it shows as a code tag instead of a li tag. Probably we need to eliminate these leading whitespaces.

leeoniya commented 10 years ago

i'm not 100% clear on how to reproduce the bug. reMarked.js converts HTML to markdown. can you please provide your exact input html, reMarked's output and what your expected output looks like. for example:

html

<ol>
  <li><strong>foo</strong></li>
  <li><em>bar</em></li>
</ol>

output

1.  **foo**
2.  _bar_

expected

1. **foo**
2. _bar_

thanks!

jatin0502 commented 10 years ago
</b><i>Test&nbsp;</i><b>Test&nbsp;</b>Test&nbsp;
<div>
  <ol>
    <li><span style="line-height: 1;"><b>Test</b>&nbsp;<i>Test&nbsp;</i></span></li>
    <li><span style="line-height: 1;"><i>Test&nbsp;</i><b>Test&nbsp;</b></span></li>
  </ol>
  <span style="line-height: 1;">
    <ul>
      <li><span style="line-height: 1;"><b>Test&nbsp;</b><i>Test&nbsp;</i></span></li>
      <li><span style="line-height: 1;"><i>Test&nbsp;</i><b>Test</b></span><br></li>
    </ul>
  </span>
</div>

While tring to convert the above HTML to Markdown, I see multiple errors.

leeoniya commented 10 years ago

sorry, you're still not providing all the information that i asked, so i cannot help you. please tell me what you expect the markdown to be for this html. also, what "multiple errors" are you seeing? in which browser? nodejs?

i have added a a couple patches in the meantime:

  1. fix: retains &nbsp; as-is.
  2. new: hoist leading and trailing &nbsp;s out of inline elements
  3. new: option to replace &nbsp;s with regular spaces
  4. new: options to strip <div> and <span> tags

see options: https://github.com/leeoniya/reMarked.js/blob/master/reMarked.js#L31-L33

if you enable these, you will get better/cleaner output for your html:

_Test_ **Test** Test 

1.  **Test** _Test_ 
2.  _Test_ **Test**     

* **Test** _Test_ 
* _Test_ **Test**  
leeoniya commented 10 years ago

closing this for lack of activity. please re-open if this is still an issue.