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
15 19875
"Chris F.A. Johnson" <cf********@gma il.comwrites:
On 2007-05-12, Sherm Pendley wrote:
>"Chris F.A. Johnson" <cf********@gma il.comwrites:
>>On 2007-05-11, Andy Dingley wrote: On 11 May, 03:31, Yogi <yogeshwersha.. .@gmail.comwrot e:
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
On Fri, 11 May 2007 21:13:49 -0400, "Chris F.A. Johnson"
<cf********@gma il.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.
On 2007-05-12, Sherm Pendley wrote:
"Chris F.A. Johnson" <cf********@gma il.comwrites:
>On 2007-05-12, Sherm Pendley wrote:
>>"Chris F.A. Johnson" <cf********@gma il.comwrites:
On 2007-05-11, Andy Dingley wrote: On 11 May, 03:31, Yogi <yogeshwersha.. .@gmail.comwrot e: > >I have a quick question. In my html document, I want to make a new >paragrap h 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)
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
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>
On 12 May 2007 17:39:01 -0700, Yogi <yo************ *@gmail.comwrot e:
>... 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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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)
My main problem is: getting each paragraph into my vector array - so
that each paragraph sits in a new array element. Eg: when i referance
array elemant 2 it will give me paragraph which is in that element and
not all paragraphs in the text file...
|
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 while statement checking
for an empty string "" which I understand represents an EOF in Python.
The text file has some blank lines with spaces and other with blanks.
Thanks a lot.
|
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 the remaining page to fill and
print blank lines with the same number of fields as the line items. In
addition, if there were a long list of line items that carried over to a
second and possibly more pages, to print blank lines at the last page. The...
|
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
Heading2
|
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 to adjust their
appearance (except ctrl-k ctrl-f)? Foremost how to clear unnecessary
blank lines, e.g reduce 4 blank lines to one. I don´t want to change
every class manually.
Thanks in advance for any hint.
| |
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.
I have logic that counts each line as I create them for the output and when I am ready for a page break, I use (55 - LineCount) to give me the number of blank lines I need to generate.
The problem I have is I want to loop/iterate to the end...
|
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 there is a blank before each paragraph. I need to know how do I tell the program to find those blank lines.
Please help!
Thanks
|
by: sskk |
last post by:
how can i split by blank lines?
split(\r\n\r\n,$arr)
like this?
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |