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

Do not emit newline after <img> tag. #170

Merged
merged 1 commit into from May 26, 2015
Merged

Do not emit newline after <img> tag. #170

merged 1 commit into from May 26, 2015

Conversation

dmitshur
Copy link
Collaborator

  • This changes HTML renderer not to always add a newline character after tags. This is desirable because tags can be inlined, and sometimes you want to avoid whitespace on left and right sides. Previous behavior of always adding a newline would unavoidably create whitespace after tag.
  • Update all tests to match new behavior. There are few changes, and they're completely isolated to inline image tests.

Fixes #169.

Change Overview

Consider the following Markdown input:

Title
===

An inline image ![img](http://www.example.com/image.png) looks like that.

![standalone image](http://www.example.com/image.png)

Another paragraph.

Previously, this would generate the following HTML output:

<h1>Title</h1>

<p>An inline image <img src="http://www.example.com/image.png" alt="img" />
 looks like that.</p>

<p><img src="http://www.example.com/image.png" alt="standalone image" />
</p>

<p>Another paragraph.</p>

After this PR, it will generate this instead:

<h1>Title</h1>

<p>An inline image <img src="http://www.example.com/image.png" alt="img" /> looks like that.</p>

<p><img src="http://www.example.com/image.png" alt="standalone image" /></p>

<p>Another paragraph.</p>

That looks like an improvement in rendering to me, and I think this change should be done.

This changes HTML renderer not to always add a newline character after
<img> tags. This is desirable because <img> tags can be inlined, and
sometimes you want to avoid whitespace on left and right sides. Previous
behavior of always adding a newline would unavoidably create whitespace
after <img> tag.

Update all tests to match new behavior. There are few changes, and
they're completely isolated to inline image tests.

Fixes #169.
@xyproto
Copy link

xyproto commented May 25, 2015

Tested the no-newline-after-img branch. It solved the problem here. The pull request looks good.

rtfb added a commit that referenced this pull request May 26, 2015
Do not emit newline after <img> tag.
@rtfb rtfb merged commit 93ae1e8 into master May 26, 2015
@rtfb
Copy link
Collaborator

rtfb commented May 26, 2015

Great, thanks, Dmitri!

@dmitshur dmitshur deleted the no-newline-after-img branch May 26, 2015 08:50
@dmitshur
Copy link
Collaborator Author

Thanks for reviewing and merging!

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

Successfully merging this pull request may close these issues.

Links are rendered with additional newlines
3 participants