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

Plain, Paragraph and parse_blocks #76

Open
kysko opened this issue Jun 27, 2024 · 2 comments
Open

Plain, Paragraph and parse_blocks #76

kysko opened this issue Jun 27, 2024 · 2 comments

Comments

@kysko
Copy link

kysko commented Jun 27, 2024

Not sure if this is intended or a bug.

If a multiblock document ends with a text line (only Inlines) not followed by a new line, that last line is interpreted as a Plain, not a Paragraph.

More generally, here are some results when applying parse_blocks to the following strings:

s1 = "A\n\nB"     -- A will be a Para, B will be a Plain
s2 = "A\n\nB\n"   -- A will be a Para, B will be a Plain
s3 = "A\n\nB\n\n" -- A will be a Para, B will be a Para

It seems to me that B should be a Para for s1 and s2, like in s3.

If however this is as intended, please disregard.

@Omikhleia
Copy link
Contributor

Might also relate to #63 -- the workaround there too is to inject a few blank lines at the end of the input.

@kysko
Copy link
Author

kysko commented Jun 27, 2024

True, but for my needs I'm more interested in the general case with parse_blocks. I should have titled better, which I'll do right away.

For now, my workaround is:

  • remove trailing blanklines;
  • check if there's a blank line in the string
  • If there is one, add two trailing blanks to force a Para;
  • if there's none, do nothing to keep the Plain (if it is indeed a Plain; if it was a block, no harm done in either case).

It's good enough for now.

@kysko kysko changed the title Plain and Paragraph at end of document Plain, Paragraph and parse_blocks Jun 27, 2024
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