I'm building a layout and need to ensure some div heights expand to fill gaps as content in the divs grows. It has to be doable with inline style="..." CSS on divs, as this is embedded in a wiki page and i can't add stylesheets, javascript, etc.
In the following layout, LEFT-TOP-LEFT and LEFT-TOP-RIGHT need to span equally to the top of LEFT-BOTTOM. Sidebar 1 and Sidebar 2 need to both span down to Footer.
The basic HTML structure i'm using is as follows. The widths are simplified; in actuality the two sidebars are more like 15% and 15%. If it'd be easier with a different structure, i'm open to that too.
<div style="font-size:10px;width:40em;margin:0;padding:0;background-color:#eee;color:#333;line-height:1.2em;">
<div style="background-color:#ddd;border:1px solid #aaa;">header</div>
<div style="float:left;width:20em;">
<div style="float:left;width:20em;">
<div style="float:left;width:10em;background-color:#aff;">
<p>LEFT-TOP-LEFT Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed
auctor faucibus diam vitae rutrum. Cras feugiat, orci in pulvinar mattis, sem
eros laoreet ligula, auctor sollicitudin nibh massa vitae ipsum. In non interdum ante.</p>
</div>
<div style="float:left;width:10em;background-color:#ccf;">
<p>LEFT-TOP-RIGHT Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam
nonummy nibh euismod tincidunt ut.</p>
</div>
</div>
<div style="clear:both;width:20em;background-color:#aaf;"><p>LEFT-BOTTOM Lorem ipsum
dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut.</p>
</div>
</div>
<div style="float:right;width:20em;">
<div style="float:right;width:20em;">
<div style="float:left;width:10em;background-color:#77a;">
'''Sidebar 1'''<p>RIGHT-1</p></div>
<div style="float:left;width:10em;background-color:#a77;">
'''Sidebar 2'''<p>RIGHT-2 Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Sed auctor faucibus diam vitae rutrum. </p></div>
</div>
</div>
<div style="clear:both;color:#333;background-color:#ddd;"> Footer </div>
</div>
Try adding style="min-height:200px;"
I'd definitely use display: table/table-row/table-cell:
http://jsfiddle.net/GW848/
Edit: noticed that the bottom element should only span to columns. Unfortunately rowspan and colspan are not available in CSS so you'll need to solve it some other way then.
Related
I have a .txt file that contains text that is formatted like so:
Neque porro, quisquam est qui
dolorem ipsum quia, dolor (sit amet)
consectetur, adipisci velit,Lorem Ipsum
dolor sit amet, consectetur adipiscing elit
tempor ipsum quia, minim (sit minim)
consectetur, adipisci velit,Lorem Ipsum
There are multiple text items like this. I wish to make it so that they are all one liners each so I can paste them into excel like so
Neque porro, quisquam est qui dolorem ipsum quia, dolor (sit amet) consectetur, adipisci velit, Lorem Ipsum
dolor sit amet, consectetur adipiscing elit tempor ipsum quia, minim (sit minim) consectetur, adipisci velit,Lorem Ipsum
Would there be any way to do this for files with a lot of text that are like this?
If you did want to use Excel (as your question indicates) this formula work if you had all text in a single cell
=SUBSTITUTE(SUBSTITUTE(A1,CHAR(10)&" "," "),char(10),REPT(char(10),2))
I want to navigate the div tag using Beautiful Soup to extract some data.
HTML Structure looks similar to this:
<div id="important-data">
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </p>
<p> <b> Heading Goes here </b> </p>
<p> Paragraph goes here </p>
<ul>
<li> Item 1 </li>
<li> Item 2 </li>
<li> Item 3 </li>
</ul>
<p> Lorem 2 ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </p>
</div>
The Original HTML doc may contain more than 30 nested tags (including other tags such as span or may be even nested divs) inside the div and I need to navigate them all
Until now, I extracted the HTML and stored in a variable
important_data_to_be_extracted = soup.find("div", id="important-data").prettify()
## Soup here is the HTML given above
The Output I'm expecting is:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Heading Goes here
Paragraph goes here
Item 1
Item 2
Item 3
Lorem 2 ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Most importantly I want the EOL to be present. I tried a few techniques using .children generator or find_all() methods, but those seem too naive and clumsy.
Is there an efficient way to extract data from the structure?
You can make use of .contents which returns back a list of all the contents of a tag
and similarly .children
from bs4 import BeautifulSoup as bs , Tag
html = '''
<div id="important-data">
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </p>
<p> <b> Heading Goes here </b> </p>
<p> Paragraph goes here </p>
<ul>
<li> Item 1 </li>
<li> Item 2 </li>
<li> Item 3 </li>
</ul>
<p> Lorem 2 ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </p>
</div>'''
soup = bs(html, 'html.parser')
div = soup.find("div", id="important-data")
for t in div.children:
if type(t)== Tag :
tag_text = t.text.strip()
print(tag_text)
Output:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua.
Heading Goes here
Paragraph goes here
Item 1
Item 2
Item 3
Lorem 2 ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
from bs4 import BeautifulSoup
html = """
<div id="important-data">
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </p>
<p> <b> Heading Goes here </b> </p>
<p> Paragraph goes here </p>
<ul>
<li> Item 1 </li>
<li> Item 2 </li>
<li> Item 3 </li>
</ul>
<p> Lorem 2 ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </p>
</div>
"""
soup = BeautifulSoup(html, 'html.parser')
target = soup.find("div", id="important-data")
print(target.text.strip())
Output:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Heading Goes here
Paragraph goes here
Item 1
Item 2
Item 3
Lorem 2 ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
When writing a long footnote with LilyPond 2.17.25, the text is not breaking into several lines or respecting the margin limits. I would love to have it set to justified alignment as well, if that is possible.
Here is a tiny example:
\version "2.17.25"
{
\footnote #'(-1 . 1)
\markup{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut eget ante venenatis mi consectetur ornare. Cras facilisis dictum venenatis. Donec.}
a'4 b' c'' d''
}
Thanks a lot!
The solution is to simply add \justify or \wordwrap to the \markup command, as:
\version "2.17.25"
{
\footnote #'(-1 . 1)
\markup\justify{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut eget ante venenatis mi consectetur ornare. Cras facilisis dictum venenatis. Donec.}
a'4 b' c'' d''
}
I need to insert the line number before each line of text using Vim, and there has to be a space after the line number. For example, if this was TestFile:
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Morbi nunc enim, vehicula eget, ultricies vel, nonummy in, turpis.
It should look like this
1 Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
2 Morbi nunc enim, vehicula eget, ultricies vel, nonummy in, turpis.
I have been using the command :%s/^/\line('.')/ with a number of variations, but I cannot figure out how to get the space at the end.
Any ideas?
You were very close!
This substitution will do the job by concatenating the string ' ' to the line number:
%s!^!\=line('.').' '!
This is probably easiest with an external tool:
:%!nl -ba -w1 -s' '
You can use a macro. First make sure you have a 0 before the first line and have your cursor placed on it:
0 Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Morbi nunc enim, vehicula eget, ultricies vel, nonummy in, turpis.
foo
bar
etc...
Then perform this key sequence to store the right macro in register a: qaywjP0<C-A>q.
Now press #a to execute the macro. Use a quantifier to execute it multiple times.
Type :help q to find out more about recording macro's.
I have long section titles in my document like:
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Proin nibh augue, suscipit a, scelerisque sed, lacinia in, mi.
Now I want to place it in page header but it is to long for it. Is there any way to cut text in LaTeX? I want to have it like that:
Lorem ipsum dolor sit amet, consectetur...
Is that possible?
https://tex.stackexchange.com/questions/6862/how-can-i-display-a-short-chapter-name-in-the-header-and-a-long-chapter-name-in-t