What is the best way to break HTML text on slashes (/)?

tl;dr; (edited Apr 2022) Use <wbr> word-break-opportunity element before each /. See first link in further reading below. Details (original from 2014) While the css word-wrap: break-word; does work, its implementation is different across browsers. If you have control of the content and want exact breakpoints, you can insert a <wbr> word break (supported in … Read more

Remove extra line breaks after Html.fromHtml()

Nice answer @Christine. I wrote a similar function to remove trailing whitespace from a CharSequence this afternoon: /** Trims trailing whitespace. Removes any of these characters: * 0009, HORIZONTAL TABULATION * 000A, LINE FEED * 000B, VERTICAL TABULATION * 000C, FORM FEED * 000D, CARRIAGE RETURN * 001C, FILE SEPARATOR * 001D, GROUP SEPARATOR * … Read more

How to display a line break with outputText?

That’s indeed not valid since Facelets because it’s syntactically invalid in XML. You’d need to manually escape the XML special characters like <, > and so on. <h:outputText value=”&lt;br/&gt;” escape=”false” /> You can however just emit the <br/> in template text without the need for a <h:outputText>. <br/> To render it conditionally, wrap it in … Read more

Code line wrapping – how to handle long lines

In general, I break lines before operators, and indent the subsequent lines: Map<long parameterization> longMap = new HashMap<ditto>(); String longString = “some long text” + ” some more long text”; To me, the leading operator clearly conveys that “this line was continued from something else, it doesn’t stand on its own.” Other people, of course, … Read more