DTP


 
Lively discussions on the graphic arts and publishing — in print or on the web


Go Back   Desktop Publishing Forum > General Discussions > Web Design

Reply
 
Thread Tools Display Modes
Old 10-25-2011, 12:49 PM   #1
dacoyle
Member
 
dacoyle's Avatar
 
Join Date: Aug 2005
Location: Arlington, VA (across the river from Washington, DC)
Posts: 560
Default RegEx help needed to close <p> tags.

Hey, folks, long time no see. How's everyone been?

My office is currently doing a full redesign and, unlike the last time ~10 years ago, we're moving from static HTML to a really cool CF system we built in house. Some of the pages we're converting haven't been touched in more than a decade so we have a lot of re-coding to do to get them to validate to current standards.

We have shortcuts for most of the fixes, but one of the most time consuming is fixing pages where the <p> tags don't have corresponding </p> tags. Is it possible to write a RegEx that can look for a <p> tag, look for the NEXT <p> tag, and insert a </p> if there isn't one there? Ideally, ignoring white space.

We have Dreamweaver, HomeSite, and TextPad available so please specify if the RegEx is tool-specific.

Thanks,

Dennis

   
__________________
Dennis
dacoyle is offline   Reply With Quote
Old 10-25-2011, 02:15 PM   #2
curveto
Member
 
curveto's Avatar
 
Join Date: Feb 2005
Location: some room with white padded walls ... now surrounded by Saguaro Cacti
Posts: 352
Default

It may be easier to blindly inject </p> before each <p> (yielding </p><p> ... simple to do that, of course). Then, search for the inversion case (i.e., \<p\>(.+)\<\/p\>(.*)(\<\/p\>)\<p\> ) removing the second </p> with <p>\1</p>\2<p>.

The "i.e.," RE is just dumped from my head so *don't* feel free to blindly copy/paste (followed by something stupid like change all, save all /w no prompts). ;

Last edited by curveto; 10-25-2011 at 02:16 PM. Reason: more detail
curveto is offline   Reply With Quote
Old 10-25-2011, 02:25 PM   #3
dacoyle
Member
 
dacoyle's Avatar
 
Join Date: Aug 2005
Location: Arlington, VA (across the river from Washington, DC)
Posts: 560
Default

I think that may be an approach we hadn't considered. Without RegEx, we've done search/replace on <p> and replacing with </p><p>, then fixing fewer errors. I'll pass this on to my scripter, but what tool was the RE written for? I'm a novice on RE after many years, but I know Dreamweaver requires different syntax than HomeSite.

   
__________________
Dennis
dacoyle is offline   Reply With Quote
Old 10-25-2011, 02:29 PM   #4
curveto
Member
 
curveto's Avatar
 
Join Date: Feb 2005
Location: some room with white padded walls ... now surrounded by Saguaro Cacti
Posts: 352
Default

That RE (sample) just came out of my brain (which is generally a mental mixture of Visual Studio and BBEdit).

...the ()s mark something for later re-insertion via \1 \2, etc. Some tools use {} and /1 /2 or other things...
curveto is offline   Reply With Quote
Old 10-26-2011, 01:37 AM   #5
dacoyle
Member
 
dacoyle's Avatar
 
Join Date: Aug 2005
Location: Arlington, VA (across the river from Washington, DC)
Posts: 560
Default

I have a developer on my team that knows how to write REs and this might be enough to get him started. He was just stumped on the approach.

   
__________________
Dennis
dacoyle is offline   Reply With Quote
Old 10-26-2011, 08:09 PM   #6
BobRoosth
Member
 
Join Date: Jan 2005
Location: Los Angeles, Ca.
Posts: 942
Default

Seems to me my copy of DW automatically corrects that sort of error when I open a mal-formed file.
BobRoosth is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regex Question Andrew B. General Publishing Topics 2 09-20-2011 07:46 PM
Need Regex help Andrew B. General Publishing Topics 7 05-08-2011 08:56 AM
RegEx help dacoyle Web Site Building & Maintenance 6 04-14-2009 07:48 AM
meta tags and leading one on...'-}} terrie Web Site Building & Maintenance 4 08-09-2006 02:02 PM
Useful info on meta tags ktinkel Web Site Building & Maintenance 3 04-22-2005 12:37 PM


All times are GMT -8. The time now is 09:18 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Contents copyright 2004–2019 Desktop Publishing Forum and its members.