Advanced HTML multiline formatting - removing not need spaces from new lines - html

Question is very simple but I am not found solution yet - probably it is not possible or very hard to find since it is very trivial.
Question is how to avoid adding spaces in formatted HTML after new line - especially in list of values.
First example see example:
1, 2
It produces required HTML like this:
1, 2
Now another example which not works:
1
,
2
It produces invalid HTML like this:
1 , 2 required is 1, 2
How to achieve same result as in first example but using multiline text layout - I know that we could do it in one line but want to do in many lines to simplify program code (not HTML).

It works as defined: in normal content, a newline is equivalent to a space. There is no way to change this principle in HTML. Just divide you content into lines so that the principle works for you, not against you. That is, break a line only at a point where a space is OK.

Related

Find Replace text FOO with Style "Heading 1" with <h1>Foo</h1>

I am trying to find an easy way to convert my Word documents to HTML without the awful save-as that is built in. These are structured documents (designed for our screen-reader (JAWS) users), and so they use Heading 1, 2, 3, 4 & the Table of Contents.
We plan to convert these to DAISY audiobooks (https://en.wikipedia.org/wiki/DAISY_Digital_Talking_Book ) , so we need pretty clean, but structured, HTML to convert.
I tried the find-replace, using Styles, but it would just replace anything in the text part of the search. I could convert it from any one style to another, but adding text in the box messed it up.
(I think I see that CSS for DAISY means that instead of just <h2> it will have to be <level2 class=='section' <h2> and closing tags), but that's step 2 after I handle this part.)
I just want to be able to find any text using Style 2 and add text to the start of that line saying "yep, here's some style 2" so that I can do the HTML/CSS stuff.
Thanks!
You can do that with a simple Find/Replace. For example, specify the Heading 1 Style for the Find parameter and use:
Replace = <h1>^&</h1>
For a macro you could incorporate that into, see: Convert a Word Range to a String with HTML tags in VBA

Display text as html markup

I have a problem which is probably trivially easy but I can't seem to get it working. Using this post, I do a search using Regex in a text string to convert any links into html markup, but when it comes to display on the page it just displays like this:
this is link
<a href='http://www.google.com'>http://www.google.com</a>
In the view I have:
<p>#news.Body</p>
edit: great my question is now displaying how I want. So now to the actual question, how do I get the page displaying an actual link instead of the code when displayed to the user.
Use `` around your variable (e.g.)
Use "{}" icon in toolbar to insert code
Indent your code by one empty line, 4 spaces and leading empty line
E.g.:
Like this
You can edit this answer to see raw output

How to remove a div from the entire project?

I've got a project consisting of over 200 html files. There's a div repeated throughout most of these, looking like this:
<div class='foobar' id="abcdef123'></div>
I have found all uses of the class using the Find in Files function in Sublime Text 2 - now I want to remove them, i.e. completely delete any line containing that div (and its closing tag).
Is there an easy way to do it in Sublime Text 2?
EDIT: I have forgotten to mention that sometimes the div has additional classes and the ID is always different. How would I write a regexp to deal with that?
In Notepad++, open all 200 files and replace with the following regular expression.
<div class='foobar[^']*' id="[^']*"></div>
and replace it by nothing. I don't know Sublimetext2.

Flex4.6 StyleableTextField ignores <br> and <p> tags

I've got a StyleableTextField in my mobile project, which gets filled with html text using the .htmlText property.
The tag is working fine for me, but simple line breaks or paragraphs are simply ignored. What can I do about that?
Basically, the simplest HTML will just be displayed as a single line:
textField.htmlText = "<p>this should be the first line</p><p>this the second one</p>";
Again, the output is a single line.
The Flex 3 doc states that those tags are definitely supported, so I reckon they simply removed it in the newer versions (which is kinda ridiculous!).
I don't want to use the stagewebview, so what other ways to I have to properly format HTML using the StyleableTextField, or is there a simple replacement for the aforementioned tags?
Thank you very much guys!
Make sure that multiline is set to true, otherwise it will treat it as a single line of text, effectively ignoring the formatting.

Perl formatting (i.e.sprintf) not retained in html display

I have ran into a bit of problem. Originally, I have the following input of the format:
12345 apple
12 orange
I saved the first column as $num and second column as $fruit. I want the output to look like this (see below). I would like for the output to align as if the $num are of all the same length. In reality, the $num will consists of variable-length numbers.
12345 apple
12 orange
As suggested, I use the following code:
$line = sprintf "%--10s %-20s", $num, $fruit;
This solution works great in command-line display, but this formatting is not retained when I try to display this via HTML. For example..
print "<html><head></head><body>
$line
</body></html>";
This produces the same output as the original before formatting. Do you guys have a suggestion as to how I can retain the sprintf formatting in html web-based display? I try to pad the $num with whitespaces, but the following code doesn't seem to work for me.
$num .= (" " x (10 - length($num)));
Anyways, I would appreciate any suggestions. Thanks!
HTML ignores extra whitespace. And the fact that it's probably displaying with a proportional font means it wouldn't line up even if the extra spaces were there.
The easy option is to just surround the text with <pre> tags, which will display by default with a monospace font and whitespace preserved. Alternatively, you can have your code generate an HTML table.
HTML compresses all consecutive spaces down to one space. If you want your output to be lined up like a table, you have to actually put the values in an HTML table.
The 'pre' in <pre> means preformatted, which exactly describes the output of a sprintf() statement. Hence the suggestion from friedo and I suspect, others.