Comments (14)
My issue is a big white space following p
tags, and marginBottom has no effect 👎
from react-native-htmlview.
@zarcode In a multiline string (denoted by backticks `<p>...</p>`
) newlines are preserved. I suspect this is what you're seeing. Compare the behaviour of the following:
import React from 'react';
import HTMLView from 'react-native-htmlview'
export default class App extends React.Component {
render() {
const htmlContent = `<p>Hello this text is <strong>Bold</strong> and this one is <em>italic</em></p><blockquote><p>quote</p></blockquote><ul><li>item1</li><li>item2</li><li>item3</li></ul>`
return (
<HTMLView value={htmlContent} />
)
}
}
Presumably the content you're displaying will be arriving in a non-preformatted way, so you should be ok. The spacing between blockquote and paragraph is a little wonky though.
from react-native-htmlview.
I see why now. Its wrapping the text component that you're attempting to apply a style to with another text component, which overrides the margin.
from react-native-htmlview.
@richchurcher bingo!
I suggest to add a trim when sharing the value prop
<HTMLView value={myContent.trim()} />
from react-native-htmlview.
I don't have the same issues like you. But I had whitespaces after the
tags and the htmlview package creates a new Text Component after a break but does not remove the whitespace.
So the new Text element starts with a whitespace.
function removeTailingWhiteSpaces(text) {
return text.replace(/\s*(<br \/> | <br>)\s*/gi, '<br\>')
}
This is my current hack for that. But it would better to have this in the package.
Maybe you have similar problems.
from react-native-htmlview.
IMO, biggest issue of the library. Can't control bottom margin on p
tags.
from react-native-htmlview.
This is driving me nuts. I've forked this repo and modified to to a barebones version, and for some reason rendering Text
elements inside the parent View
component just ignores margins. Other styling works (like colors), but for some bewildering reason, it ignores margins on text elements.
from react-native-htmlview.
@gregblass did you mean <Text><Text></Text></Text>
and we're trying to style the inner Text
? :(
from react-native-htmlview.
Is there a fix for that?
from react-native-htmlview.
@tiendq Yep, exactly.
@WorldWideWebb No. I modified this library pretty heavily for my own project. The double Text
are gonna be hard coded in there because of the way it was written. I needed control over my paragraph margins and wanted to add stuff like unordered list items, etc.
If I remember correctly, every component gets wrapped in a parent Text component, which is what is causing the margins to be ignored.
from react-native-htmlview.
I believe this was the culprit: https://github.com/jsdf/react-native-htmlview/blob/master/htmlToElement.js#L42
So the 'text' there represents actual raw text, which gets put into a Text
component.
That gets wrapped in a parent Text
component here, recursively: https://github.com/jsdf/react-native-htmlview/blob/master/htmlToElement.js#L95
Parent text component doesn't take any styles as props, and React Native ignores the child Text
margins and padding if they are passed in.
from react-native-htmlview.
Ah - yes. I see what's going on.
from react-native-htmlview.
So of the problems reported in the OP, the <pre>
and <ol>
issues are solved. The first issue,
1. Use <a href="http//asciiflow.com/" rel="nofollow">http://asciiflow.com/</a> to generate diagram<p>2. Use Ascii to SVG<span></span>
now produces:
1. Use
http://asciiflow.com/
to generate diagram
2. Use Ascii to SVG
which I guess is marginally better in that it recognises a paragraph should break to a new line! The broken appearance of the rest of the text is because each inline element is receiving a newline, which is obviously not ideal but appropriately summarised in #114 so I'm going to close this.
from react-native-htmlview.
@gregblass @kengorab anyone can help me with this issue
https://www.screencast.com/t/8hOZoocMHS
I am getting too much whitespaces between elements. This is how html looks:
<p>Hello this text is <strong>Bold</strong> and this one is <em>italic</em>. Add some link <a href="http://some.com" target="_blank">link</a> not <del datetime="2017-08-10T06:02:09+00:00">deleted</del>.</p>
<blockquote><p>quote</p></blockquote>
<ul>
<li>some</li>
<li>item2</li>
<li>item3</li>
</ul>
<ol>
<li>some</li>
<li>item2</li>
<li>item3</li>
</ol>
Also as you can see first <p>
is too high ( marked blue )
from react-native-htmlview.
Related Issues (20)
- Unordered List followed by Paragraph not rendering properly HOT 3
- Space between html tags is huge even tho I wrapped my content in "<div>" HOT 4
- Inline styling is not working HOT 1
- Get text of clicked links
- How to set the number of lines to show HOT 1
- Truncate text in html view HOT 1
- Get raw html in renderNode HOT 2
- Make HTML Text selectable HOT 4
- Multiple HyperLinks
- img tag have default border HOT 1
- Update HTMLView TS definitions to support class components
- <sup> and <sub> tag not working HOT 3
- Typing for HTMLViewNode on Typescript HOT 2
- dynamically set height according to available content
- import ViewPropTypes from deprecated-react-native-prop-types instead of react-native HOT 5
- Is there a way to ignore links ? HOT 1
- Error: Invariant Violation: ViewPropTypes has been removed from React Native. Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types'. HOT 3
- can add katex css to this html view ? HOT 1
- Please Help me to Solve this Error << ViewPropTypes has been removed from React Native. Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types'. HOT 2
- ViewPropTypes will be removed from 'react-native' HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-htmlview.