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

violation of GFM example #287 #1591

Closed
Inilien opened this issue Jan 6, 2020 · 6 comments · Fixed by #2112
Closed

violation of GFM example #287 #1591

Inilien opened this issue Jan 6, 2020 · 6 comments · Fixed by #2112
Labels
category: lists L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue

Comments

@Inilien
Copy link

Inilien commented Jan 6, 2020

Describe the bug
I couldn't find setings in the demo of marked which would give the expected by GFM specification behavior for the example #287

To Reproduce
It is best to just use the link above.

I duplicate it here though too:

- foo
  - bar
    - baz


      bim

should look like this:

  • foo
    • bar
      • baz

        bim

While marked behaves like this

Expected behavior
bim should be just another paragraph in the last list item and not a code block

@styfle styfle added category: lists L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue labels Jan 6, 2020
@styfle
Copy link
Member

styfle commented Jan 6, 2020

Thanks for reporting!

This is a known issue as seen in the test suite here (notice the shouldFail flag):

"markdown": "- foo\n - bar\n - baz\n\n\n bim\n",

Would you like to submit a PR to fix it?

@UziTech
Copy link
Member

UziTech commented Jan 6, 2020

similar to #1503

@alexanderankin
Copy link

image

This is the regular expression, as i understand it, that is not giving enough text back.

list: /^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,

i dont know what exactly needs to happen in order for it to do that, augment it with the paragraph recognizer text? Here is the actual hyper text markup it is outputting:

<ul><li>foo<ul><li>bar<ul><li>baz</li></ul></li></ul></li></ul>
<pre><code>  bim</code></pre>

and what i managed to get it to was <ul><li><p>foo</p></li><li><p>bar... but it would still produce the bim in its own code tag with some spaces inside the tag.

@alexanderankin
Copy link

alexanderankin commented May 24, 2020

heres my attempt at breaking down what the regex does:

/
  ^           # start of string
  ( {0,3})    # first level < 4 spaces
  (bull)      # bullet point is * or -, etc. (resolved line 47)
  ' '         # space
  [\s\S]+?    # non-greedy (as pointed out) non/white space
  (?:         # non capturing group
    hr        # hr (also resolved later)
      |       # OR
    def       # def (also resolved later)
      |       # OR
    \n{2,}       # two+ newlines
    (?! )        # which are not followed by spaces
    (?!\1bull )  # & not flwd by same indent+bullet+space
    \n*          # are followed by any number of newlines
      |          # OR
    \s*$      # whitespace til new line
  )
/

maybe whitespace til new line needs to allow for new lines? or maybe instead add a fifth branch to the conditional. It would appear that having the other ones produce paragraphs would not satisfy the test (and may break others). anyways at this point put enough time to realize i should walk away for today.

@UziTech
Copy link
Member

UziTech commented May 24, 2020

[\s\S]+? # optional 1+ non/white space

+? actually means non-greedy 1+. It will try to match the least possible instead of the most possible.

@calculuschild
Copy link
Contributor

This will be fixed by #2112

@styfle styfle linked a pull request Jun 24, 2021 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: lists L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants