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.

Support for html inside text

See original GitHub issue

First of all, I just wanted to say thanks for putting this together!

I think it would be great if there was support for html inside text. In other words something like the Trans component in next-translate.

My use case is a long paragraph with different styling for different parts of the text. The alternative would be to just have a bunch entries in my .json translations file, instead of one for the whole paragraph.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
martinkrcommented, Nov 5, 2021

Yes, innerHTML, totally depends on your threat model. You can also think about using the translated string through something like https://github.com/cure53/DOMPurify

Cheers!

1reaction
xkal36commented, Nov 5, 2021

Thanks for replying so quick and for the suggestions! I can see how the first suggestion would work and guess it should be fine from a security since it’s me adding the html. I will give this a go and if it doesn’t work out, will maybe submit a PR to add something like the Trans component I mentioned

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML Text Formatting - W3Schools
Formatting elements were designed to display special types of text: ... The HTML <ins> element defines a text that has been inserted into...
Read more >
HTML text fundamentals - Learn web development | MDN
This article explains the way HTML can be used to structure a page of text by adding headings and paragraphs, emphasizing words, creating...
Read more >
Rendering HTML inside textarea - javascript - Stack Overflow
An addendum to this: You can use character entities (such as changing <div> to <div> ) and it will render in the textarea....
Read more >
Structural markup and right-to-left text in HTML - W3C
This article looks at ways of handling text direction for structural markup in HTML, ie. at the document level and for elements like ......
Read more >
HTML text control in Power Apps - Microsoft Learn
An HTML text control not only shows plain text and numbers but also converts HTML tags, such as non-breaking spaces. Note. HTML text...
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