Skip to content
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

Nested unordered lists parsing/indentation issue #48

Closed
brianmock opened this issue Mar 5, 2018 · 3 comments
Closed

Nested unordered lists parsing/indentation issue #48

brianmock opened this issue Mar 5, 2018 · 3 comments

Comments

@brianmock
Copy link

brianmock commented Mar 5, 2018

Running into an issue where nested bullets are improperly indented.

Some background, I use react-rte (https://github.com/sstur/react-rte) to convert a user's rich text input to markdown which I pass to a Markdown component:

  0 import React from 'react';
  1 import SimpleMarkdown from 'simple-markdown';
  2
  3 import Content from 'components/Content';
  4
  5 const Markdown = ({ string, className }) => {
  6   if (!string) {
  7     return null;
  8   }
  9
 10   const mdParser = SimpleMarkdown.defaultBlockParse;
 11   const mdOutput = SimpleMarkdown.defaultOutput;
 12
 13   const syntaxTree = mdParser(string);
 14
 15   const content = mdOutput(syntaxTree);
 16
 17   return (
 18     <Content className={className}>
 19       {content}
 20     </Content>
 21   );
 22 };
 23
 24 export default Markdown;

An example of the issue -- when I pass the following string (generated by the react-rte lib) to the Markdown component above:

- test one
    - thing one
- test two
    - thing two
    - one more thing two
- test three
    - thing three
- test four

I end up with the following output, you'll notice the one more thing two item is treated as a new ul when it should only be considered another list item of the current ul:
screen shot 2018-03-05 at 10 46 34 am
screen shot 2018-03-05 at 10 45 57 am

Does not happen for ordered lists.

Here is a link to the syntaxTree output generated by the mdParser function.
Let me know if there is any additional info you need to help figure out what's going on. Thanks.

@ariabuckles
Copy link
Owner

Confirmed; I think I have an idea what's going on and can probably fix it this week, although it might take a bit of time as I'm pretty busy at work right now.

Thanks!

@ariabuckles
Copy link
Owner

I just pushed version 0.3.3 with a potential fix for this - could you let me know if it works for you (and whether it introduces any other surprises).

[I expect it to work and not cause problems, of course, but it fixes this in an unusual way and like most things, could potentially interact oddly with custom extensions]

@brianmock
Copy link
Author

@ariabuckles Looks great so far! Thanks for the quick turnaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants