question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

White spaces were not rendered

See original GitHub issue

First words

I think the cause is on this line: HTML.js#L269 (The regex pattern /\s/g )

Is this a bug report or a feature request?

Bug report.

Have you read the guidelines regarding bug report?

No.

Have you read the documentation in its entirety?

Yes.

Have you made sure that your issue hasn’t already been reported/solved?

I have searched. It could be alternative to #118

Is the bug specific to iOS or Android? Or can it be reproduced on both platforms?

Tested on Android.

Is the bug reproductible in a production environment (not a debug one)?

Not tested yet.

Have you been able to reproduce the bug in the provided example?

Not tested yet.

Environment

Environment: React: 16.6.0-alpha.8af6728 React native: 0.57.4 react-native-render-html: 3.10.0

Target Platform: Android (7.0)

Steps to Reproduce

  1. Render html with a tag contain white spaces only (unicode white space)

Expected Behavior

white spaces should be rendered. They are not breaking spaces.

(Write what you thought would happen.)

Actual Behavior

White spaces were not rendered.

Reproducible Demo

Not implement yet.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
grnkvchcommented, May 20, 2019

Same problem, only spaces between 2 html tags like

render() {
    const html = '<strong><em>Hello</em><strong> <strong>World</strong>';
    return (<HTML html={html}/>);
}

Result: HelloWorld

Shitty fix:

const html = '<strong><em>Hello</em><strong> <strong>World</strong>';
const fixedHtml = html.replace(/> </g, '><span style="color:white;">-</span><');

.replace(/>\s</g, ‘>&shy; <’) works as well

3reactions
alexisbronchartcommented, May 20, 2019

This line https://github.com/archriss/react-native-render-html/blob/928d8e825377181f383934f0b33747ae1315f345/src/HTML.js#L272 could be replaced with: const strippedData = data && data.replace(/\s+/g, ' ') It seems to work fine, at least for my use case. @Exilz @bd-arc do you guys think it would be OK to merge this? I can send a PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JSX not rendering whitespace - javascript - Stack Overflow
I have an array of individual characters, that I am using to map out a string. However, the whitespace is being ignored. How...
Read more >
HTML white space entities &ensp;/&emsp; not rendered correctly
It seems the svelte compiler removes   if it is not accompanied by additional non-whitespace characters within the same textnode. you ...
Read more >
How whitespace is handled by HTML, CSS, and in the DOM
Most whitespace characters are ignored, not all of them are. In the earlier example ... still exists when the page is rendered in...
Read more >
White space automatically removed when rendering
In the attached workflow when i try to render a table with one record with the sentence: This is a doubly spaced sentence....
Read more >
White-space processing in XAML - Microsoft Learn
Consistent with XML, white-space characters in XAML are space, linefeed, ... between each ListBoxItem) is not preserved and not rendered.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found