peternewnham / react-html-parser

Converts HTML strings directly into React components and provide a simple way to modify and replace the content.
https://peternewnham.github.io/react-html-parser
MIT License
781 stars 103 forks source link

Add some styles when convert node to element #71

Open phuongthuan opened 4 years ago

phuongthuan commented 4 years ago

Here we can convert ul to ol tag, but how we can add some styles for the tag that we converted.

function transform(node, index) {
  // convert <ul> to <ol>
  if (node.type === 'tag' && node.name === 'ul') {
    node.name = 'ol';
    return convertNodeToElement(node, index, transform);
  }
}
teamnhip4 commented 3 years ago

Hi bro, i just found a solution that resolved problem. Just add a property style in attribs node.attribs.style = 'color: red';