html textarea injecting line breaks - html

I've got a weird problem.
I have an html textarea, with the cols set to 84, like so:
<textarea id="caseNote_note0" class="txtArea" name="caseNote_note" style="line-height: 1.1em; height: 5em;" wrap="hard" rows="10" cols="84" tabindex="7">blah blah blah</textarea>
The txtArea class is defined as:
.txtArea {
font-family:arial,sans-serif;
font-size:1.0em;
width:99%;
rows:10;
overflow:hidden;
border:none;
font-family:arial,sans-serif;
margin: 0px 3px 0px 3px;
}
The textarea is stretched across almost the whole screen.
When the user types in data, the data all appears in the textarea as you would expect.
However, when you submit the form, the text looks like its been saved with line breaks injected into it.
i.e.
before the save:
-------------------------------------------------------------------------------
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah
-------------------------------------------------------------------------------
after the save:
-------------------------------------------------------------------------------
blah blah blah blah blah
blah blah blah blah blah
blah blah blah blah blah
blah blah blah blah blah
blah blah blah blah blah
blah blah blah blah blah
-------------------------------------------------------------------------------
If I change the cols to be greater than 84 (say 150), the linebreaks appear later (i.e. more text shows before a line break seems to get enetered).
The text is also being saved in the database table with these apparent mystery line breaks.
A wordaround is to set the cols to something really high (like 500), then I guess I wouldn't run into this problem....but I'd rather know why this is happening in the first place.
Any help is appreciated!
Cheers
Jarrett

Remove the wrap attribute. It’s unneeded.

Your problem is caused by the wrap="hard" attribute in the HTML. You can change it to wrap="soft" to wrap the lines on screen but not include them into the submitted data. Alternatively you can change it to wrap="off" to turn wrap off completely - textarea will then include a horizontal scrollbar.
Here's one page describing this in details (this one is from Microsoft), but searching the web for textarea wrap will give you loads more.

Related

aligning a line of text left in a paragraph? CSS/HTML

I have a line of text like so:
I am john doe blah blah blah.
How can I align it like so:
I am john doe
blah blah blah
Several ways:
Set the width of the text container so that the desired line break
occurs
Use <br> where you want the line break
Wrap each 'line' of text in a <span>, and style them with CSS for the desired effect.
The 'right' way really depends on context. Perhaps you could say more about that.
Use the line break element <br>.
Example:
My name is Adam and i live in<br>South Africa.
will display as:
My name is Adam and i live in<br> South Africa

Multi-line bullet list in markdown

Does markdown supports multi-line (line-break inside the item) bullet list? In HTML, I can put <br> inside it.
Item 1
blah blah blah
Item 2
blah blah blah
UPDATED in Jan 2020
Thank you for your contribution. Two trailing spaces work in the Jupyter environment.
Two spaces at the end of line are used to insert a line-break.
Example (replace the two dots with two spaces!):
* Item..
some indented text
This will render as:
Item
some indented text
A more markdown-friendly alternative (to accepted answer) is to add 2 trailing spaces to the first line.
Alternative to double trailing space you can add a trailing backslash.
* Item 1\
blah blah blah
* Item 2\
blah blah blah
rendered to
* Item 1
blah blah blah
* Item 2
blah blah blah
Oh I just checked <br> also works in markdown too...
You may check out this.
* unordered list
+ sub-item 1
+ sub-item 2
- sub-sub-item 1
* unordered list
+ sub-item 1
+ sub-item 2
- sub-sub-item 1

css counter-increment for section numbers

I am trying to get the css Counter to work. It works fine until I have a,b,c in one of the list items, then it messes up. This is what I want to display
1. ACKNOWLEDGEMENTS
1.1 blah blah blah
1.2 blah blah blah
1.3 blah blah blah
2. Risk Statement
2.1 blah blah blah
2.2 blah blah blah
2.3 blah blah blah
3. License
3.1 blah blah blah
3.2 blah blah blah
a blah blah blah
b blah blah blah
c blah blah blah
3.3 blah blah blah
4. License
4.1 blah blah blah
4.2 blah blah blah
4.3 blah blah blah
What is happening is that a,b,c is being counted so 3.3 is displaying as 4.3 and then section 4 is starting at 5.1....Here it is in JSFiddle(a,b,c are not showing but ignore that - the numbering is the important thing)... http://jsfiddle.net/XQKcy/11/
The ol li will affect all li elements within the list, even those of child ol elements.
As such you need to identify the immediate children, and only apply to those, using ol>li syntax.
See the updated fiddle - http://jsfiddle.net/XQKcy/14/

Removing/compacting superfluous XML/HTML tags from command line?

Consider this snippet, obtained from an export:
<!--l. 266--><p class="indent" >
<span
class="ptmr8t-x-x-90">“</span><span
class="ptmri8t-x-x-90">Blah blah blah, </span>
<span
class="ptmri8t-x-x-90">blah blah, blah blah blah, </span>
<span
class="ptmri8t-x-x-90">blah blah, blah blah, blah blah blah </span>
<span
class="ptmri8t-x-x-90">blah blah, blah </span>
<span
class="ptmri8t-x-x-90">blah blah, blah blah, blah</span>
<span
class="ptmri8t-x-x-90">blah blah, blah </span><span
class="ptmr8t-x-x-90">(</span><a
href="#X0-cite"><span
class="ptmr8t-x-x-90">Testing </span>
<span
class="ptmr8t-x-x-90">Ref, </span><a
href="#X0-cite"><span
class="ptmr8t-x-x-90">1980</span></a></a><span
class="ptmr8t-x-x-90">, pg.1)”</span>
</p>
EDIT: I concur with comments, that there is no general way to specify what is superfluous - this is what I meant: This code snippet is essentially meant to represent a single line as rendered HTML:
... and since all of that "bla bla..." in the content line is meant to be in the same format, I consider pieces of it carrying separate span tags that specify the same format (and indeed they are the same tags, without change in attributes, just <span class="ptmri8t-x-x-90">) to be superfluous - even if they aren't nested.
Running an XML formatter/pretty printer on this (say, xml_pp -i a.xml) to indent our tags will result with the following code:
<!--l. 266--><p class="indent">
<span class="ptmr8t-x-x-90">“</span>
<span class="ptmri8t-x-x-90">Blah blah blah, </span>
<span class="ptmri8t-x-x-90">blah blah, blah blah blah, </span>
<span class="ptmri8t-x-x-90">blah blah, blah blah, blah blah blah </span>
<span class="ptmri8t-x-x-90">blah blah, blah </span>
<span class="ptmri8t-x-x-90">blah blah, blah blah, blah</span>
<span class="ptmri8t-x-x-90">blah blah, blah </span>
<span class="ptmr8t-x-x-90">(</span>
<a href="#X0-cite">
<span class="ptmr8t-x-x-90">Testing </span>
<span class="ptmr8t-x-x-90">Ref, </span>
<a href="#X0-cite">
<span class="ptmr8t-x-x-90">1980</span>
</a>
</a>
<span class="ptmr8t-x-x-90">, pg.1)”</span>
</p>
Note that here:
we have sequences of <span class="X">text A, </span><span class="X">text B, </span> which are pointless, as they could be reduced to <span class="X">text A, text B, </span>
We have double nested <a href="#X0-cite"> - again pointless, could do without the inner one
Eventually, I'd like to run something, and obtain the following "compacted" code:
<!--l. 266--><p class="indent" >
<span
class="ptmr8t-x-x-90">“</span><span
class="ptmri8t-x-x-90">Blah blah blah,
blah blah, blah blah blah,
blah blah, blah blah, blah blah blah
blah blah, blah
blah blah, blah blah, blah
blah blah, blah </span><span
class="ptmr8t-x-x-90">(<a
href="#X0-cite">
Testing
Ref,
1980</a>
, pg.1)”</span>
</p>
... where text whitespace is preserved (and individual portions of superfluous tags are removed on each line separately), and a case like <a href="#X0-cite"> interrupting a sequence of <span>s is handled; which I could then prettify to:
<!--l. 266--><p class="indent">
<span class="ptmr8t-x-x-90">“</span>
<span class="ptmri8t-x-x-90">Blah blah blah,
blah blah, blah blah blah,
blah blah, blah blah, blah blah blah
blah blah, blah
blah blah, blah blah, blah
blah blah, blah </span>
<span class="ptmr8t-x-x-90">(<a href="#X0-cite">
Testing
Ref,
1980</a>
, pg.1)”</span>
</p>
Is there a (Linux) command line tool that could help me do the "compaction" like described? awk or regex scripts could do it, I guess - but it seems kinda complex for that...
Many thanks in advance for any answers,
Cheers!
There is nothing prebuilt that you could use.
What you are asking for changes the DOM that would be generated from the markup. The usual case for minification seeks to change the markup without changing the model it represents.
Your white space preservation requirements are also asking for it to preserve data that doesn't expressed by the markup (since whitespace isn't collapsed except in CDATA blocks).

Css style to avoid inserting line breaks

My html looks something like this:
<p>blah blah blah blah blah blah <b>something that I want
on a single line</b> blah blah blah</p>
I want to somehow communicate that I want the bold section to start a new line if and only if it can't fit onto the current line. Basically I need a way to say "don't split this across lines if theres any possible way to avoid it"
Is there any facility in html or css to express this?
Try setting white-space: nowrap; on the <b> tag.
You can add non-breaking spaces - - between the words, i.e.
<p>blah blah blah blah blah blah
<b>something that I want on a single line</b> blah blah blah</p>
You can use non breaking spaces between the words by using .
You can use the CSS white-space property with the nowrap value to acheive this.
In your case:
b{
white-space:nowrap;
}
I'd recommend using the <strong> tag rather than the <b> also since the former is semantically more correct.