Adding new lines to Alert text - apache-flex

I want to create a simple multiline Alert popup
Alert.show("Blah\\nBlah")
shows Blah\nBlah when what I really want is two lines, one Blah each.

If it is anything like most languages, then you only need to have \n to get a new line. having \\n is saying that you actually do want to draw a \ because normally the back slash is used to say you're about to do some thing special.

Try:
Alert.show("Blah\nBlah")

Related

INDESIGN: Replace column break with paragraph return

I am using Adobe Indesign. I want to replace all the column breaks (numberpad enter) with paragraph returns without having to do each and every one. Is there a simple way to do this? I've tried using the find/change feature, but I haven't found anywhere in there that I can easily search for a column break and paragraph return.
Just use GREP and appropiate metacharacters

Prepend text to file without creating a line break with SaltStack

I am using saltstack to managed configuration on my servers. I have a use case where I need to prepend text to the beginning of the file WITHOUT creating a line break.
Currently:
/path/to/file:
file.prepend:
- text:
here is some text to add
This works great ACCEPT for the fact that "here is some text to add" is added on a new line at the top of the file. I need this text to be prepended at the beginning of the file without creating a new line break. I would love to do this with saltstack but I cannot find a solution to this problem anywhere in their documentation.
The text being added on a new line at the beginning of the file creates things to not work as expected. I have found a few examples of how to do this using sed or a bash script but would love to be able to use saltstack to accomplish this.
Has anyone experiences this same problem that can point me in the right direction?
I was able to come up with a solution for this using pattern matching and replacing.
add_text_to_start:
file.replace:
- name: /path/to/the/file
- pattern: text that will always be at the beginning
- repl: here is some text to add text that will always be at the beginning
The text that is at the beginning of the file will always be at the beginning of the file. So by matching the pattern I am able to add text to the beginning of the file without having to add a line break. All the rest of the text that follows the "text that will always be at the beginning of" is untouched and will be in the same place that is was in before the pattern find and replace occurred.

How to represent markdown properly with escaping and line breaks?

I'm currently trying to build a chat app, using the official markdown package as well as underscore's escape function, and my template contains something like this:
<span class="message-content">
{{#markdown}}{{text}}{{/markdown}}
</span>
When I grab the text from the chat input box, I try to escape any HTML and then add in line breaks. safeText is then inserted into the database and displayed in the above template.
rawText = $("#chat-input-textbox").val();
safeText = _.escape(rawText).replace(/(?:\r\n|\r|\n)/g, '\n');
The normal stuff like headings, italics, and bold looks okay. However, there are two major problems:
Code escape issue - With the following input:
<script>alert("test")</script>
```
alert('hello');
```
This is _italics_!
Everything looks fine, except the alert('hello'); has become alert('hello'); instead. The <pre> blocks aren't rendering the escaped characters, which makes sense. But the problem is, the underscore JS escape function escapes everything.
SOLVED: Line break Issue - With the following input:
first
second
third
I get first second third being displayed with no line breaks. I understand this could be a markdown thing. Since I believe you need an empty line between paragraphs to get linebreaks in markdown. But having the above behaviour would be the most ideal, anyone know how to do this?
UPDATE Line break issue has been solved by adding an extra \n to my regex. So now I'm making sure that any line break will be represented with at least two \n characters (i.e. \n\n).
You should check the showdown docs and the wiki article they have on the topic.
The marked npm package, which is used by Telescope removes disallowed-tags. These include <script> of course. As the article I linked to above explains, there's still another problem with this:
<a href='javascript:alert("kidding! Im more the world domination kinda guy. Muhahahah")'>
click me for world peace!
</a>
Which isn't prevented by marked. I'd follow the advice of the author and use a HTML sanitation library. Like OWASP's ESAPI or Caja's html-sanitizer. Both of these project's seem outdated dough. I also found a showdown extension for it called showdown-xss-filter. So my advice is to write your own helper, and use showdown-xss-filter.

Aptana: find and replace tabs (with spaces)

I am belatedly setting up Aptana to use four spaces instead of tabs. I've made the necessary changes to the preferences so every new tab inserts four spaces.
All the existing tabs remain, however, and so I get Mixed spaces and tab errors. How can you do a Replace all to fix this? I've tried ^t, <TAB> etc but it just searches for these as normal strings. What are the correct ways to specify a space and a tab?
I've found myself in similar situation and copying whole source code and repasting it helped me out. Just do as follow on your source code Ctrl+A, Ctrl+C, then Del whole code and Ctrl+V it again. You will get only spaces if have set it in options like you mentioned above.
There's an option in the refactor source menu to convert between tabs and space-tabs.
This worked for me: Edit > Find/Replace... (CTRL+F), check Regular Expressions, type \t and type 4 spaces (I use 4 spaces for tab).

Ask: Replace multiple new line into single new line or br

I have problem with replace character.
If I have one textbox, and I write into textbox with many new line.
and the results I wanted a lot of new lines replaced with one or two new lines such as comments in the facebook.
I'l try this code :
litText.Text = System.Text.RegularExpressions.Regex.Replace(Text1.Text, "[\\r\\n]+", "<br /><br />", System.Text.RegularExpressions.RegexOptions.Multiline);
this works if I press a lot of button enter,but this isn't works if I press button enter once then displays new line twice. I want if I press once or two button enter, fixed display once or two new line. except three times or more than two.
please your assistance and your opinions.
Thank you
You want to duplicate the entire \r\n multiple times, as opposed to just duplicating one of them like in your example. Also you should use #"..." for this.
litText.Text = System.Text.RegularExpressions.Regex.Replace(
Text1.Text, #"(\r\n|\r|\n)+", "<br>",
System.Text.RegularExpressions.RegexOptions.Multiline);

Resources