Show multiline text in grails page - string

I'm going mad with this, I need to show a text I got from a textarea in grails 2.3.7 but when I replace \r\n characters for br/ and do an encodeAsHTML() I get the br's every where instead of new lines.
How is it done? this is what I've tried:
${cotizacionInstance.descripcion.encodeAsHTML().replaceAll('\r\n', '<br/>')}
${cotizacionInstance.descripcion.replaceAll('\r\n', '<br/>').encodeAsHTML()}
<%=cotizacionInstance.descripcion.replaceAll('\r\n', '<br/>').encodeAsHTML()%>
<%=cotizacionInstance.descripcion.encodeAsHTML().replaceAll('\r\n', '<br/>')%>
<%=cotizacionInstance.descripcion.replaceAll('\r\n', '<br/>').decodeHTML()%>
<%=cotizacionInstance.descripcion.decodeHTML().replaceAll('\r\n', '<br/>')%>
I don't like the way it comes out if I use the pre tag, because I loose all responsiveness.
I see that in the google chrome inspector I get my string between double quotes but I don't know how to remove those.
Thanks

There are factors left out of your description which make it impossible to say for sure but one way to get the behavior you are after is to mark the text as raw with something like this...
${raw(cotizacionInstance.descripcion.replaceAll('\r\n', '<br/>'))}
I hope that helps.

You need to esacpe your backslashes:
replaceAll("\\n", "<br/>")

Related

Printing literal ' in React Native text object

I want to print:
Hi, let's do this:
the issue is, it won't work with the "let's" due to the apostrophe. If I use quotes around this (""), it prints the quotes as well in the view, which I don't want.
How do I do this in React Native?
Try this
<Text>{"Let's"}</Text>
Try <Text>{"Hi, let's do this"}</Text>.
Any time you encounter any difficulty using a Text label, just remember that inside the brackets the rules of JavaScript apply, and so you can do anything in the same way that you would for a JS string.
A temporary work around is to use ' instead of '

Mediawiki/wikipedia text format issue

so i got an issue with text formatting and i have no idea how this problem is called or what i should search after, so i thought i try to explain it here.
It's literally nothing dramatic or should take long, i simply want to write stuff like
''italic'' or '''bold'''
without that it actually gets italic or bold... i literally want
''italic''
to be displayed. I've also tried to use code blocks but even within the blocks it writes italic then.. i'm sure there is a <..> command but i simply can not find it
Does anyone know?
try this:
<nowiki>''italic''</nowiki>

How to pass a longer caption, with spaces, via "instagram://camera?caption"?

Is it possible to pass a longer caption through the camera or is it limited to one word?
I've seen this example:
instagram://camera?caption=hello
But could I use something like this?
instagram://camera?caption=hello%20world
Yes this should work fine for you.
The documentation hasn't really been published very well but you can see here for people URL encoding

How to replace/remove specific strings from html file using Notepad++?

I've export my bookmarks from FF in to a html file but it's too huge and complicated, so I need to remove some firefox lines from it to make it more lighter and plain.
I can replace basic things in the Notepad++ but I guess I do need some operators for this and I have no idea how to make it work right.
For example here is the line from the file containing a link to Logodesignlove :
Logo Design Love
I need to remove all those tags I don't care about, like LAST_MODIFIED="1256428672", ICON_URI="bunch of digits" ICON="bunch of characters" etc.
And of course I need to remove all those tags in every link in the list.
So I was thinking like use something like "Find all tags LAST_MODIFIED="anynumbers" and replace it with nothing/remove it" - it doesn't work though.
Examle how it should like:
Logo Design Love
So far I removed LAST_MODIFIED and ADD_DATE lines thanks to Aleksandr. So LAST_MODIFIED="\d+" worked just fine. But ICON and ICON_URI are still there. I've tried ICON="\w+" - but it doesn't work. I guess it has something to do with the slashes.
Why look for what you don't want when it's easier to keep hold of what you do want and drop the junk?
(<A HREF=".*?").*?(>.*?>)
with
$1$2
Code edited to suit Notepad++ now I know it doesn't need the special chars escaped. Thanks Aleksandr.
Read up on using regular expressions (the java regex tutorials are a good start http://docs.oracle.com/javase/tutorial/essential/regex/), and try one of the online regex tools to help write and test it, such as this one http://gskinner.com/RegExr/
Eg, remove "LAST_MODIF..." with the regex LAST_MODIFIED="\d+"
Otherwise, you may want an XML-specific tool, or even write an XSL. However, I don't know much about that.

JTextArea setWrapStyleWord(true) does not work if appending text

According to Oracle at JTextArea documentation, if you wish to wrap lines AND wrap at word boundaries and not character boundaries you must use code as follows:
jtaOutputPrimes.setLineWrap(true);
jtaOutputPrimes.setWrapStyleWord(true);
Please note that the jtaOutputPrimes is the name of my JTextArea on my JPanel.
The issue comes in when I use the method append to add text to the JTextArea as follows:
jtaOutputPrimes.append(",");
In this case, the setWrapStyleWord setting does not work. It continues to use the character boundaries and not the word boundaries.
I have found another person experiencing same issue here: setWrapStyleWord issue
Now, lets say you are running an JApplet that has this JTextArea. If you type in the text area, it will word wrap fine, but any passed text from the append method does not work.
I believe this is a bug, and I cannot find Oracle acknowledge it as such anywhere.
Can anyone help? Thanks!
I found out why this was happening, and this simple fix may be beneficial to others. The issue came into play because when I appended the comma (,) to the JTextArea it was eliminating the white space between words. To fix this, I simply placed a space after the comma like so, and it worked.
jtaOutputPrimes.append(", ");

Resources