How to write preformatted text in a form? - html

The goal is to be able to use tabulations and other special characters.
I thought I could use <pre> tag and put a form inside it but it doesn't work.
Thanks.

If I understand correctly, you may achieve the same goal by using html entities
For example
<pre>
(\/)
(^.^)
(")(")
</pre>
Equals this:
&nbsp&nbsp(\/)<br>&nbsp(^.^)<br>(")(")

Related

How to convert plain text to html but keep the display format?

I have one plain text which is program output, but I want to display it in html page. But still I want to keep the formats (like space/tab/enter and etc.), it's just like the code block of stackoverflow, how can I display it properly in html ? Thanks
Use the "pre" and "code" HTML tags:
<pre><code> code in here... </code></pre>
<code> the program</code>

Mediawiki -- change code tag to respect single newline?

Is there a way to force the <code> tag respect single lines in Mediawiki? I really don't want to have to use the Poem extension because then I think it looks ugly. For example:
<poem>
<code>
Here's a block of code.
With two lines.
</code>
</poem>
I think that looks a bit bad... Any suggestions on just allowing the code tag to do the trick alone?
Nevermind. Just simply use <pre class="code"> and this does exactly every single thing I want to do.
One can also use https://www.mediawiki.org/wiki/Extension:SyntaxHighlight which handles new lines fine, too.
Example code:
<syntaxhighlight lang="css">
.class {
some-css;
}
</syntaxhighlight>

How to show the string inside a tag verbatim?

What tag can I use to prevent any interpretation? I need that because I need to write down some source code and it's result in blogger. I have this code in blogspot, but the code inside the <pre> is processed
The code is as follows:
<pre class='prettyprint'>
$latex \displaystyle S(n)=\sum_{k=1}^{n}{\frac{1}{T_{k}}=\sum_{k=1}^{n}{\frac{6}{k(k+1)(k+2)}$
</pre>
This is the result:
$latex \displaystyle S(n)=\sum_{k=1}^{n}{\frac{1}{T_{k}}=\sum_{k=1}^{n}{\frac{6}{k(k+1)(k+2)}$
When I can replace '$' in <pre> with something equivalent, I could avoid this issue.
I tried <code> and <pre>, but they all interpret the content.
ADDED
I'm trying to use the javascript code found in this post.
If I understand correctly, you are using Replacemath, and its documentation says: “Should you need to to prevent certain $ signs from triggering LaTeX rendering, replace $ with the equivalent HTML <span>$</span> or $, or put the code inside a <pre> or <code> block if appropriate.” Of these, the first method seems to actually work.
That is, replace all occurrences of “$” inside the pre element by <span>$</span>.
I tested this by publishing a test in my blog (which had been dormant for 6 years...). I had to manually break the pre block to fit into the column.

How can I escape a sequence of HTML so it can go inside a tags title attribute?

I've been working on this for way too long. I'm trying to put HTML inside the title attribute of a tag. This is for a tooltip. Of course, if this is going to be possible, then I have to escape all of the necessary characters so it doesn't screw up the tag in which it is contained. To be specific, how can I fit the following inside the title attribute of a tag:
test
That is, I want this:
<div title="test">my div</div>
I feel like I've tried everything. Is this even possible?
I googled HTML Escape Characters and found a tool to do it: http://accessify.com/tools-and-wizards/developer-tools/quick-escape/default.php
It produced this string which you can use:
<a href="test">test</a>
if you are using jquery you can do it like this
$('div').attr('title','test');
if you want to escape html tags then you simply can do this
if your test is in a div something like this
<div id="tag">test</div>
then you can do $('div').attr('title', $("#tag").text());

HTML <code> blocks - Should HTML tabs display inside?

Within a standard code block, should HTML appear exactly as written?
For example, if I put the following:
<code>
<script type="text/javascript">Something in javascript</script>
</code>
Should it appear exactly as above?
I assume the code button here on stackoverflow is doing something else other than just putting it in ?
Thanks!
There are certain characters that must be encoded even in the code block. My preference is converting the less than, greater than and ampersand. This handles most of the code.
To make tags appear as they are use the <pre> tags instead:
<pre>
<script type="text/javascript">Something in javascript</script>
</pre>
No. <code> isn't even block-level. It also depends on whether you mean "traditional" HTML or XHTML.