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

Text spills to wrong element (image nesting) #211

Closed
step- opened this issue Jan 10, 2024 · 2 comments
Closed

Text spills to wrong element (image nesting) #211

step- opened this issue Jan 10, 2024 · 2 comments

Comments

@step-
Copy link
Contributor

step- commented Jan 10, 2024

This case involves hard breaks within the text of nested images.

Test subject:
(two spaces after lines 1, 2 and 3)

![outer BR  
![inner BR  
inner image](test.png)  
outer image](./test.png)

cmark:

<p><img src="./test.png" alt="outer BR inner BR inner image outer image" /></p>

Above we see that cmark conflates all text into the alt attribute. This is the recommended way of handling nested images for HTML (as you commented in your source code).

On the other hand something goes the wrong way in md2html, which lets the text in line 4 spill over to the containing <p> element.

mdview:

<p><img src="./test.png" alt="outer BR inner BR inner image"><br>
outer image</p>
@mity
Copy link
Owner

mity commented Jan 10, 2024

I think this is duplicate of #210.

@mity mity closed this as completed Jan 10, 2024
@step-
Copy link
Contributor Author

step- commented Jan 10, 2024

Now it passes my test suite. I think the reason we aren't seeing this problem after #210 is that now r->image_nesting_level is 1 for the outer image, and 0 when outside any image, so https://github.com/mity/md4c/blob/ca169a9/src/md4c-html.c#L504 doesn't output a hard-break anymore (see also L508 for soft break).

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

No branches or pull requests

2 participants