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

Server-side markdown parsing removes linebreaks from paragraphs between lists #3204

Closed
kueda opened this issue Sep 1, 2021 · 0 comments · Fixed by #3205
Closed

Server-side markdown parsing removes linebreaks from paragraphs between lists #3204

kueda opened this issue Sep 1, 2021 · 0 comments · Fixed by #3205

Comments

@kueda
Copy link
Member

kueda commented Sep 1, 2021

Describe the bug
As reported in the Forum, paragraphs entered between lists lose their linebreaks.

To Reproduce
Steps to reproduce the behavior:

  1. Go to to your journal and make a new draft post
  2. Enter this the following text:
    List 1
    1. point 1
    2. point 2
    
    In between Paragraph 1
    
    In between Paragraph 2 
    
    In between Paragraph 3 
    
    List 2
    1. point 1
    1. point 2
    
    Extra paragraph 1
    
    Extra paragraph 2
    
    Extra paragraph 3
  3. Preview that and you'll see the "In between" paragraphs are all on one line, when they should have linebreaks between them:
    Screen Shot 2021-09-01 at 11 16 40 AM

Note that this does not happen in our JS markdown parsing, e.g. for comments and IDs.

Expected behavior
It should look like Github markdown parsing:

List 1

  1. point 1
  2. point 2

In between Paragraph 1

In between Paragraph 2

In between Paragraph 3

List 2

  1. point 1
  2. point 2

Extra paragraph 1

Extra paragraph 2

Extra paragraph 3

Context
Since this only seems to be happening in server-side markdown parsing, presumably this affects everyone.

Additional context
This is probably a problem with ApplicationHelper#formatted_user_text

seanclifford added a commit to seanclifford/inaturalist that referenced this issue Sep 2, 2021
Fixes inaturalist/inaturalist#3204

Paragraphs were not being applied when in between 2 sections of tables,
lists or preformatted text.
This was because the regex used was greedy, and would  include
everything between the first and last of one of those tags, rather than
stop matching after the first end tag it finds.

Fix was to apply the non-greedy `?` modifier to the `*`s
kueda pushed a commit that referenced this issue Sep 2, 2021
Fixes inaturalist/#3204

Paragraphs were not being applied when in between 2 sections of tables,
lists or preformatted text.
This was because the regex used was greedy, and would  include
everything between the first and last of one of those tags, rather than
stop matching after the first end tag it finds.

Fix was to apply the non-greedy `?` modifier to the `*`s
kueda added a commit that referenced this issue Oct 13, 2022
This should fix #3529 but allows #3204 to regress.
simple_format_with_structure probably just needs to be re-written with a more
comprehensive recursive strategy so it can strip whitespace within list
elements while still applying simple_format to elements between sibling
lists (or tables, or pres)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant