Line break in "notes" content on new TASK creation through API (JSON) - asana

I like to get some Line breaks in the notes content on task creation, I tried <br>, </br> , /r/n , /n/r and some ASCII too. Nothing worked, I am using JSON object through JAVA code.

As Eric pointed out, you'll want to use \n, which is the correct encoding for a newline in this case (as it should be in any JSON API you come across).

Related

Undo email wordwrap line breaks in Ruby

My Rails app processes incoming emails by splitting them into multiple lines. This is what I currently use on the plain text version of the body: lines = email.body.split("\n")
This works well unless the sentences are longer than ~74 characters as most email clients will automatically add a line break per RFC 2822.
Example email: https://gist.github.com/marckohlbrugge/39c17b928eb17d330d63
Looking at the plain text part there seems to be no way to discern between a line break added by the user versus the email client. You could ignore any line break happening at the 75th position, but I think there might be a chance of false positives. (I could be wrong.)
The HTML part has all the information we need, but I'm not sure about a universal way to process this. Is replacing every div and br with a newline and then stripping al other HTML elements enough? What about all the other block-element tags? What about inline elements styled as block-elements? What if an email doesn't have an HTML part?
I did find some interesting code examples in Convert HTML to plain text (with inclusion of s), but replacing a list of html tags with newlines doesn't seem like a complete (exhaustive) solution.
Is it worth looking at something like this mail library as they've probably already thought about the edge cases? ;)

grails i18n line break

Using the Grails internationalization messages.properties I'm trying to create a multi-line message, but cannot seem to find a way to create a new line without using the <br> element, and I'd prefer to keep presentation logic out of the message. I've tried using "\n" but that doesn't get rendered.
I know I can use multiple messages "message.1=...", "message.2=...", but that doesn't seem as clean either.
Here's what I'd like to be able to do:
messages.properties
helptext=First Line\nSecond Line\nThird Line
page.gsp
<g.message code="helptext"/>
result:
First Line
Second Line
Third Line
Everything I've found either says to use <br> element, or do a replaceAll on \n, but I was hoping to not have to use extra processing to handle this.
I think you have to use <br> in the message directly.
//messages.properties
helptext=First Line<br>Second Line<br>Third Line
//Gsp
<p><g:message code="helptext"/><p>
\ gives the ability to break the line in the properties file but renders as a single line in view.
For me (i18n message properties in Grails 2.0 project) worked following line:
property = Line1\\nLine2\\nLine3
HTML tag BR worked also fine if displayed on HTML page, but was not any good for me, because I in my case this text needed to be a text string not HTML.
You could write a custom tag that converts \n into br tags as well. It would just need to call the messageSource bean and parse the results. Thus your messages would not have to be HTML-specific

lua reading chinese character

I have the following xml that I would like to read:
chinese xml - https://news.google.com/news/popular?ned=cn&topic=po&output=rss
korean xml - http://www.voanews.com/templates/Articles.rss?sectionPath=/korean/news
Currently, I try to use a luaxml to parse in the xml which contain the chinese character. However, when I print out using the console, the result is that the chinese character cannot be printed correctly and show as a garbage character.
I would like to ask if there is anyway to parse a chinese or korean character into lua table?
I don't think Lua is the issue here. The raw data the remote site sends is encoded using UTF-8, and Lua does no special interpretation of that—which means it should be preserved perfectly if you just (1) read from the remote site, and (2) save the read data to a file. The data in the file will contain CJK characters encoded in UTF-8, just like the remote site sent back.
If you're getting funny results like you mention, the fault probably lies either with the library you're using to read from the remote site, or perhaps simply with the way your console displays the results when you output to it.
I managed to convert the "中美" into chinese character.
I would need to do one additional step which has to convert all the the series of string by using this method from this link, http://forum.luahub.com/index.php?topic=3617.msg8595#msg8595 before saving into xml format.
string.gsub(l,"&#([0-9]+);", function(c) return string.char(tonumber(c)) end)
I would like to ask for LuaXML, I have come across this method xml.registerCode(decoded,encoded)
Under that method, it says that
registers a custom code for the conversion between non-standard characters and XML character entities
What do they mean by non-standard characters and how do I use it?

Indy9 Get Raw Email header?

Does Indy9 have any way to get a specific raw email header (say, "Subject" or "From") which still includes the transfer-encoding (ie: has not been mangled by DecodeHeader on older versions of Delphi with poor Unicode support), or would I have to parse the entire email header manually to extract this information?
The TIdMessage.RawHeaders property is what you are looking for, eg:
Subject := IdMessage1.RawHeaders.Values['Subject'];
I have solved the problem, calling IdMessage1.Headers.Values['Subject'] BEFORE calling IdMessage1.ProcessHeaders gives different results than after.

Clean up & style characters from text

I am getting text from a feed that has alot of characters like:
Insignia&#153; 2.0 Stereo Computer Speaker System (2-Piece) - Black
4th-Generation Apple® iPod® touch
Is there an easy way to get rid of these, or do I have to anticipate which characters I want to delete and use the delete method to remove them? Also, when I try to remove
&
with
str.delete("&")
It leaves behind "amp;" Is there a better way to delete this type of character? Do I need to re-encode the text?
String#delete is certainly not what you want, as it works on characters, not the string as a whole.
Try
str.gsub /&/, ""
You may also want to try replacing the & with a literal ampersand, such as:
str.gsub /&/, "&"
If this is closer to what you really want, you may get the best results unescaping the HTML string. If so try this:
CGI::unescapeHTML(str)
Details of the unescapeHTML method are here.
If you are getting data from a 'feed', aka RSS XML, then you should be using an XML parser like Nokogiri to process the XML. This will automatically unescape HTML entities and allow you to get the proper string representation directly.
For removing try to use gsub method, something like this:
text = "foo&bar"
text.gsub /\b&\b/, "" #=> foobar

Resources