react-native-render-html icon indicating copy to clipboard operation
react-native-render-html copied to clipboard

How to style text that are not wrapped in HTML?

Open reddeguzman opened this issue 7 years ago • 4 comments

It's impossible to style text that are not wrapped with HTML tags. For example a string that comes from somewhere else and it contains combination of text that are bare and are wrapped with HTML tags

reddeguzman avatar Dec 07 '18 16:12 reddeguzman

You cant try this customWrapper={(node) => <Text style={{...common.textPrimary}}>{node}</Text>}

mrquanghuy avatar Dec 11 '18 03:12 mrquanghuy

I am unable to use font color within HTML My HTML is: var html="Text 1<font color = '#dd3936'><b>bold text with color</b></font>,hi<br><br>Also, this text<font color = '#dd3936'><b>feedback</b></font>, hello <font color = '#dd3936'><b>development.</b></font>"

 <HTML 
              html={html
              baseFontStyle={{fontFamily: this.props.getFontFamily(template.font_family),fontSize:18}}
              />

simulator screen shot - iphone 6 - 2018-12-19 at 16 05 31

AishwaryaSurana avatar Dec 19 '18 10:12 AishwaryaSurana

@AishwaryaSurana please open another issue. There's indeed a problem with your HTML string that isn't related to this question.

This is because your color is a direct attribute of <font> and not in style. This isn't supported at the moment. A good thing to do would be to check every attribute on each node and filter the styling ones to apply it.

Exilz avatar Feb 11 '19 16:02 Exilz

@reddeguzman you can style unwrapped texts by using the tagsStyle prop. Just add the following : rawtext: { color: 'red' }. This might have unintended modifications on your styling, though.

Exilz avatar Feb 11 '19 17:02 Exilz