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

fix(formatting): trailling space #205

Merged
merged 1 commit into from
Oct 9, 2017

Conversation

armandabric
Copy link
Collaborator

@armandabric armandabric commented Oct 8, 2017

Closes #135

BREAKING CHANGE: Trailling are now preserved. In some rare case, react-element-to-jsx-string failed to respect the JSX specs for the trailing space. Event is the space were in the final output. There were silentrly ignored by JSX parser. This commit fix this bug by protecting the trailing space in the output.

If we take the JSX:

<div>
  foo <strong>bar</strong> baz
</div>

Before it was converted to (the trailing space are replace by * for the readability):

<div>
  foo*
  <strong>
    bar
  </strong>
  *baz
</div>

Now there are preserved:

<div>
  foo{' '}
  <strong>
    bar
  </strong>
  {' '}baz
</div>

Closes algolia#135

BREAKING CHANGE: Trailing are now preserved. In some rare case, `react-element-to-jsx-string` failed to respect the JSX specs for the trailing space. Event is the space were in the final output. There were silentrly ignored by JSX parser. This commit fix this bug by protecting the trailing space in the output.

If we take the JSX:
```jsx
<div>
  foo <strong>bar</strong> baz
</div>
```

Before it was converted to (the trailing space are replace by `*` for the readability):
```html
<div>
  foo*
  <strong>
    bar
  </strong>
  *baz
</div>
```

Now there are preserved:
```html
<div>
  foo{' '}
  <strong>
    bar
  </strong>
  {' '}baz
</div>
```
'<div>\n \n</div>'
`<div>
{' '}
</div>`
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not like this output. But the previous one were also not pretty... so I guess we have to look at it in a dedicated PR.

Copy link
Contributor

@vvo vvo Oct 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can always provide an option to remove trailing whitespace no?, wait no, that's different. It should be kept I guess.

@armandabric armandabric merged commit 2a07d5e into algolia:master Oct 9, 2017
@armandabric armandabric deleted the fix/trailing-space branch October 9, 2017 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spaces between words and inline elements are lost
2 participants