Indentation in html textarea with spaces doesn't work as expected - html

When i'm trying to add extra spaces to html textarea to make my text be indented and wrapped in a right way I need, textarea trims these spaces and wraps text in it's own way.
Lets assume that dot (.) is a space. In this case things go in a way, I want them. The line '....some.........texts........here' will be displayed in text area of size (cols: 13) with monospace font as:
here we have a string in text area of max 13 chars length. And the string indented with one tab that represented with 4 chars at the beginning. So there are additional dots at the end of the lines, to make next part of string be on the next line in text area. And it works.
But if I use spaces instead of these dots, so the initial line is:
' some texts here'
in the same text as before it will look like
So textarea trimmed additional spaces in all places where it wrapped the string. Is there any way to avoid it?
UPD: Looks like this topic is highlighted here.

Related

How do you get tab to wrap to the next line in HTML?

When setting white-space:pre-wrap, the following HTML breaks the line on the tab, with the tab appearing at the end of the first line.
HTML:
<html>
<body>
<div style="white-space:pre-wrap; width:70px">Some text\tsome more text</div>
</body>
</html>
(where \t is the literal tab character, rather than the escape sequence)
Output (Chrome):
Some text\t
some
more text
When you adjust the width, either the tab character appears on the first line, or the whole of "text\t" drops to the next line. If you create a similar sequence in Microsoft Word, however, the tab character drops onto the second line when the line gets too small. That is, in HTML the tab is 'stuck' to the word "text", but in Microsoft Word it is 'stuck' to the word "some".
I've tried to replicate this in HTML with various combinations of white-space, word-wrap, <wbr>, etc., but without success. Using emsp or a series of nbsp appears to be output at different sizes to a literal \t character.
In HTML/CSS, is there any way to have the implicit line break in the same place, but get the tab to appear on the start of the second line instead?
Desired Output:
Some text
\tsome
more text

HTML textarea cuts off beginning new lines

An HTML text area works fine with new lines ("\n") when they're after any other content in the text area, whether it be whitespace characters like spaces or tabs ("\t") or not.
However, when text area content begins with a new line (for example, "\ntest"), that new line gets cut off on display.
Any ideas on what causes this/how to remedy it?
This seems to be by the spec.
A single newline may be placed immediately after the start tag of pre and textarea elements. If the element's contents are intended to start with a newline, two consecutive newlines thus need to be included by the author.
Note that in the past there were some bugs in the various browsers regarding leading new lines in elements:
https://bugzilla.mozilla.org/show_bug.cgi?id=591988
https://bugs.chromium.org/p/chromium/issues/detail?id=62901

inline code as a "word" in sublime text

Is it possible to make sublime text consider all code within backticks to be a single word? I am including inline code in a markdown document, and it keeps breaking when I wrap a paragraph and inserts a newline in the midst of a code chunk. For example
This is the text I am writing and `r this_is_some_code`
If the line is long, and a newline falls between `r and the final backtick, then the code doesn't work correctly. Is it possible to make that whole region be considered a single word? then it would not wrap at the ruler at all.

text input component

Is it possible to ignore white space between characters inside a text input field
let's say a user types in "bri an" instead of "brian.
Is there a way that white space is ignore and treated it as one word?
One of many ways is to use the TextField.restrict property. Simply prevent spaces from being typed into your textfield in the first place by doing this:
myTextField.restrict = "^ ";
The ^ means to disallow the following characters (in this case we are disallowing a space).
I put an example on wonderfl http://wonderfl.net/c/teOC

Best practices: displaying text that was input via multi-line text box

I have a multi-line text box. When users simply type away, the text box wraps the text, and it's saved as a single line. It's also possible that users may enter line breaks, for example when entering a "bulleted" lists like:
Here are some suggestions:
- fix this
- remove that
- and another thing
Now, the problem occurs when I try to display the value of this field. In order to preserve the formatting, I currently wrap the presentation in <pre> - this works to preserve user-supplied breaks, but when there's a lot of text saved as a single line, it displays the whole text block as single line, resulting in horizontal scrolling being needed to see everything.
Is there a graceful way to handle both of these cases?
The easiest way of dealing with this is turning all line breaks \n into <br> line breaks. In PHP for example, this is done using the nl2br() function.
If you want something a bit more fancy - like the list you quote getting converted into an actual HTML <ul> for example - you could consider a simple "language" like Markdown that SO uses. It comes with natural, simple rules like
# Heading 1
## Heading 2
### Heading 3
* Unordered List item
* Unordered List item
1. Numbered List item
2. Numbered List item
etc....
You can use the php function nl2br() It transforms line breaks into elements
Convert newline characters to <br /> tags explicitly, and let the browser word-wrap the text normally. That preserves the breaks the visitor entered, without harming other paragraphs.
You could replace line breaks with HTML line breaks.
Replace "\r\n" or "\n" (depending on the browser and platform, check first for longer one) with <br/>.
I would normally replace all CR/LF with LF, and then replace all LF with <br />. You can then render this text inside any HTML container you want and let it flow naturally.