473,406 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Blank lines and paragraph break in html

Hi there,

I have a quick question. In my html document, I want to make a new
paragraph whenever I have a blank line in the html source. Using <p>
and </pevery time is kind of cumbersome (I want to do it the LaTeX
way). Is it possible at all?

Thanks for your time,
Yogi

May 11 '07 #1
15 19844
Yogi wrote:
I have a quick question. In my html document, I want to make a new
paragraph whenever I have a blank line in the html source. Using <p>
and </pevery time is kind of cumbersome (I want to do it the LaTeX
way). Is it possible at all?
<pis the semantically correct way to mark up a paragraph. You
shouldn't want to change that.

You can style it however you like with CSS.

p { margin-bottom: 4em; }

Play with the numbers.

Sorry, what is the LaTeX way?

--
-bts
-Motorcycles defy gravity; cars just suck
May 11 '07 #2
Yogi wrote:
Hi there,

I have a quick question. In my html document, I want to make a new
paragraph whenever I have a blank line in the html source. Using <p>
and </pevery time is kind of cumbersome (I want to do it the LaTeX
way). Is it possible at all?

Thanks for your time,
Yogi
HTML stands for HyperText Markup Language. To be HTML, it must have the
markups (e.g., <p>).

In most cases, the end-tag </pis optional. I use the end-tag only
when I have declared a style for <p(e.g., via a class attribute) that
I don't want to continue into content where I don't want to declare a
new paragraph.

--

David E. Ross
<http://www.rossde.com/>.

Don't ask "Why is there road rage?" Instead, ask
"Why NOT Road Rage?" or "Why Is There No Such
Thing as Fast Enough?"
<http://www.rossde.com/roadrage.html>
May 11 '07 #3
Yogi wrote:
>
I have a quick question. In my html document, I want to make a new
paragraph whenever I have a blank line in the html source. Using <p>
and </pevery time is kind of cumbersome (I want to do it the LaTeX
way). Is it possible at all?
You can try making your content as a text file, with <preand </pre>
deliminating it, and hope for the best. I'm not sure what HTML markup
you'll be able to use inside the <preelement, but I'll leave that
discovery to you.

I must say, though, that it's a weird request. Marking up paragraphs as
paragraphs in documents is part of Web publishing. HTML is the means to
do that. Throwing out a three-byte tag because it's too long is jsut
bizarre to me. But then, I am not a follower of the LaTeX Way.

--
John
May 11 '07 #4
"Beauregard T. Shagnasty" <a.*********@example.invalidwrites:
Yogi wrote:
>I have a quick question. In my html document, I want to make a new
paragraph whenever I have a blank line in the html source. Using <p>
and </pevery time is kind of cumbersome (I want to do it the LaTeX
way). Is it possible at all?

<pis the semantically correct way to mark up a paragraph. You
shouldn't want to change that.

You can style it however you like with CSS.

p { margin-bottom: 4em; }

Play with the numbers.

Sorry, what is the LaTeX way?
The LaTeX way is for blank lines in source to denote paragraph breaks.
If it looks like a paragraph in source, it's a paragraph in the output.

sherm--

--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
May 11 '07 #5
Yogi <yo*************@gmail.comwrites:
I have a quick question. In my html document, I want to make a new
paragraph whenever I have a blank line in the html source. Using <p>
and </pevery time is kind of cumbersome (I want to do it the LaTeX
way). Is it possible at all?
You might have a look at Markdown:

<http://en.wikipedia.org/wiki/Markdown>
<http://daringfireball.net/projects/markdown/syntax>

Browsers don't understand Markdown, but many CMS systems and editors do,
and can automagically translate it into HTML.

sherm--

--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
May 11 '07 #6
On 11 May, 03:31, Yogi <yogeshwersha...@gmail.comwrote:
I have a quick question. In my html document, I want to make a new
paragraph whenever I have a blank line in the html source.
Just regex pairs of adjacent linebreaks into <p>.

s/\n(\s*\n\s*)+/\n<p>/

You can ignore the </pin HTML (but don't use XHTML).

Remember that in HTML a <pmarks the _start_ of a paragraph, not a
"paragraph break". The difference is subtle, but significant. I don't
know how TeX regards this.

Don't confuse this with <br>. That's a linebreak, which is an inline
thing not paras, and it also is a "break" marker, not a "start"
marker.

If you don't like the rendered whitespace you get, fix that with CSS,
not by changing the underlying HTML

If you really care, run the converted HTML through Tidy afterwards.
May 11 '07 #7
On 2007-05-11, Andy Dingley wrote:
On 11 May, 03:31, Yogi <yogeshwersha...@gmail.comwrote:
>I have a quick question. In my html document, I want to make a new
paragraph whenever I have a blank line in the html source.

Just regex pairs of adjacent linebreaks into <p>.

s/\n(\s*\n\s*)+/\n<p>/
That will not work. Text utilities read a line at a time, and a
line cannot contain a newline.

With awk:

awk '
/./ && empty { empty = 0; printf "<p>" }
!/./ { empty = 1 }
{print}
'

--
Chris F.A. Johnson <http://cfaj.freeshell.org>
========= Do not reply to the From: address; use Reply-To: ========
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
May 12 '07 #8
"Chris F.A. Johnson" <cf********@gmail.comwrites:
On 2007-05-11, Andy Dingley wrote:
>On 11 May, 03:31, Yogi <yogeshwersha...@gmail.comwrote:
>>I have a quick question. In my html document, I want to make a new
paragraph whenever I have a blank line in the html source.

Just regex pairs of adjacent linebreaks into <p>.

s/\n(\s*\n\s*)+/\n<p>/

That will not work. Text utilities read a line at a time
s/Text utilities/Awk/

I hate to break it to you, but Awk is not the only text utility in
the world. It may still have that old one-line-at-a-time limit, but
the rest of the world moved past that years ago.

If you use something reasonably modern - Perl, Ruby, Python, Java,
any of a variety of regex-aware editors, etc. - the above will work
just fine.

sherm--

--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
May 12 '07 #9
On 2007-05-12, Sherm Pendley wrote:
"Chris F.A. Johnson" <cf********@gmail.comwrites:
>On 2007-05-11, Andy Dingley wrote:
>>On 11 May, 03:31, Yogi <yogeshwersha...@gmail.comwrote:

I have a quick question. In my html document, I want to make a new
paragraph whenever I have a blank line in the html source.

Just regex pairs of adjacent linebreaks into <p>.

s/\n(\s*\n\s*)+/\n<p>/

That will not work. Text utilities read a line at a time

s/Text utilities/Awk/
And sed and other text utilities.
I hate to break it to you, but Awk is not the only text utility in
the world. It may still have that old one-line-at-a-time limit, but
the rest of the world moved past that years ago.

If you use something reasonably modern - Perl, Ruby, Python, Java,
any of a variety of regex-aware editors, etc. - the above will work
just fine.
Those are overkill for a simple task that can be done easily in sed
or awk.

--
Chris F.A. Johnson <http://cfaj.freeshell.org>
========= Do not reply to the From: address; use Reply-To: ========
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
May 12 '07 #10
"Chris F.A. Johnson" <cf********@gmail.comwrites:
On 2007-05-12, Sherm Pendley wrote:
>"Chris F.A. Johnson" <cf********@gmail.comwrites:
>>On 2007-05-11, Andy Dingley wrote:
On 11 May, 03:31, Yogi <yogeshwersha...@gmail.comwrote:

I have a quick question. In my html document, I want to make a new
paragraph whenever I have a blank line in the html source.

Just regex pairs of adjacent linebreaks into <p>.

s/\n(\s*\n\s*)+/\n<p>/

That will not work. Text utilities read a line at a time

s/Text utilities/Awk/

And sed and other text utilities.
s/other/other ancient, obscure, rarely used in the modern world/
>I hate to break it to you, but Awk is not the only text utility in
the world. It may still have that old one-line-at-a-time limit, but
the rest of the world moved past that years ago.

If you use something reasonably modern - Perl, Ruby, Python, Java,
any of a variety of regex-aware editors, etc. - the above will work
just fine.

Those are overkill for a simple task that can be done easily in sed
or awk.
You had to write four lines of code to work around Awk's one line at a
time limitation, when the tools I mentioned can do the same with one
line of code. You have a curious definition of "easily."

perl -p -i -e 's/^$/<p>/m' foo.html

Yeah, that one command is sooooo much more difficult than your four
lines of obscurity. Total overkill. Not.

sherm--

--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
May 12 '07 #11
On Fri, 11 May 2007 21:13:49 -0400, "Chris F.A. Johnson"
<cf********@gmail.comwrote:
That will not work. Text utilities read a line at a time, and a
line cannot contain a newline.
If your favoured stream editor can't span multiple lines, you need to
upgrade it to one that does. Plenty out there. You may well need to
supply a parameter to it to turn this feature on.

Most people these days are probably doing this inside an interactive
screen editor. jEdit in my case, which would have no problem at all
doing it.

May 12 '07 #12
On 2007-05-12, Sherm Pendley wrote:
"Chris F.A. Johnson" <cf********@gmail.comwrites:
>On 2007-05-12, Sherm Pendley wrote:
>>"Chris F.A. Johnson" <cf********@gmail.comwrites:

On 2007-05-11, Andy Dingley wrote:
On 11 May, 03:31, Yogi <yogeshwersha...@gmail.comwrote:
>
>I have a quick question. In my html document, I want to make a new
>paragraph whenever I have a blank line in the html source.
>
Just regex pairs of adjacent linebreaks into <p>.
>
s/\n(\s*\n\s*)+/\n<p>/

That will not work. Text utilities read a line at a time

s/Text utilities/Awk/

And sed and other text utilities.

s/other/other ancient, obscure, rarely used in the modern world/
>>I hate to break it to you, but Awk is not the only text utility in
the world. It may still have that old one-line-at-a-time limit, but
the rest of the world moved past that years ago.

If you use something reasonably modern - Perl, Ruby, Python, Java,
any of a variety of regex-aware editors, etc. - the above will work
just fine.

Those are overkill for a simple task that can be done easily in sed
or awk.

You had to write four lines of code to work around Awk's one line at a
time limitation, when the tools I mentioned can do the same with one
line of code. You have a curious definition of "easily."

perl -p -i -e 's/^$/<p>/m' foo.html

Yeah, that one command is sooooo much more difficult than your four
lines of obscurity. Total overkill. Not.
That doesn't do what the awk script I posted does. The awk
equivalent of your perl script is:

awk '/^$/{print "<p>"}1' foo.html

Or in sed:

sed 's/^$/<p>/'

--
Chris F.A. Johnson <http://cfaj.freeshell.org>
========= Do not reply to the From: address; use Reply-To: ========
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
May 12 '07 #13
I must say, though, that it's a weird request. Marking up paragraphs as
paragraphs in documents is part of Web publishing. HTML is the means to
do that. Throwing out a three-byte tag because it's too long is jsut
bizarre to me. But then, I am not a follower of the LaTeX Way.

--
John
Thanks for your opinion. I do not think that three-byte tag is too
long, it is just that I happen to use many paragraph breaks, and LaTeX-
way makes it a little bit easy to read the code (not a whole lot
easier though).

Thanks,
Yogi
May 13 '07 #14
Yogi wrote:
>I must say, though, that it's a weird request. Marking up paragraphs as
paragraphs in documents is part of Web publishing. HTML is the means to
do that. Throwing out a three-byte tag because it's too long is jsut
bizarre to me. But then, I am not a follower of the LaTeX Way.

--
John

Thanks for your opinion. I do not think that three-byte tag is too
long, it is just that I happen to use many paragraph breaks, and LaTeX-
way makes it a little bit easy to read the code (not a whole lot
easier though).
Obviously, you need a LaTeX browser, not an HTML browser.

--

David E. Ross
<http://www.rossde.com/>.

Don't ask "Why is there road rage?" Instead, ask
"Why NOT Road Rage?" or "Why Is There No Such
Thing as Fast Enough?"
<http://www.rossde.com/roadrage.html>
May 13 '07 #15
On 12 May 2007 17:39:01 -0700, Yogi <yo*************@gmail.comwrote:
>... I happen to use many paragraph breaks, and LaTeX-
way makes it a little bit easy to read the code (not a whole lot
easier though).
My solution is to have a nearly blank line in the code. The markup is
used, and there's enough of a visual break to assist readability.

<h2>Section Title</h2>
<p>
This is a paragraph.</p>
<p>
This is another.</p>
--

Charles
May 14 '07 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Row | last post by:
HI, I would first like to say its been about 3 years since looking at java im very rusty! I have to write a post it notes type applet which will function online. (reading from a flat text file)...
6
by: Ruben | last post by:
Hello. I am trying to read a small text file using the readline statement. I can only read the first 2 records from the file. It stops at the blank lines or at lines with only spaces. I have a...
6
by: Melissa | last post by:
Does anyone have a generic procedure for adding blank lines to reports like Sales details, PO details and/or Orders details. The procedure would need to count the number of line items, determine...
1
by: satya.mahesh | last post by:
Hi All, I am working on a problem which "eliminates blank lines in export (between headings and when a heading is empty)". I want a macro which will do this job for me. For e.g: Heading1 ...
4
by: Andreas Bauer | last post by:
Hi, I have to audit some c# code. I know in the options I can adjust how the code should be formatted while entering it. But is there any way to apply afterwards a code template to the classes...
0
by: jstendor | last post by:
I have an XML file that contains Invoices. In most cases there is a page break for cleints and I need to fill the remaining lines on the page with blanks and place a Page N of T at the bottom. ...
5
by: bigpaco | last post by:
I am trying to use looping to indent paragraphs in a file. So I need to insert blanks at the beginning of each paragraph, to do so I will need to know where the paragraph starts and it says that...
4
by: sskk | last post by:
how can i split by blank lines? split(\r\n\r\n,$arr) like this?
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.