-
1. Re: How do I move a block of text from within the <head> tag area to within the <body> tag area?
Rik Ramsay May 4, 2012 7:08 PM (in response to RickEEE)I have to ask but why would a <h3> and a <p> tag be inside a <head> tag to begin with - and then done 2500 times? This makes no sense. Also with a site that large, are you using a CMS? Or, are you using a DW template, SSI?
There could be many answers depending on how the files are set up. But, assuming they are not in a template or CMS, if you define the site in DW you can run a "find and replace" through the 'Entire Current Local Site'. To be nice and easy this would only work if everything between your out of place text and the <body> tag are the same on every page. Be a little more difficult if not.
Eg:
Find:
<head>
<h3>Blah blah</h3>
<p>Blah blah blah</p>
</head>
<body>
Replace with:
<head>
</head>
<body>
<h3>Blah blah</h3>
<p>Blah blah blah</p>
If this won't do, post the <head> section of your page up to the <body> tag and we can maybe offer more insightful responses.
-
2. Re: How do I move a block of text from within the <head> tag area to within the <body> tag area?
RickEEE May 7, 2012 6:15 AM (in response to Rik Ramsay)Great questions, Rik, and I understand how this might seem bizarre. Here's the story... these 2500 files were authored with a built-in authoring tool of our current knowledge management system. This KMS is about to be replaced with a new one and because the new KMS needs content within the <head> tag instead of where it was in the <body> tag and redefined as meta data, I repuposed the content in those files using Dreamweaver and regular expressions. However, the one remaining <h3> and <p> content is in the middle of the newly tagged meta data and it must be moved from the <head> area and into the <body> area.
Because these were authored in the built-in KMS authoring tool, there is no style sheet and no, we do not manage our content with a CMS.
You are correct, if the <h3> and <p> were at the end of the data, I could simply move the </head> and <body> tags, but unfortunately that is not the case. They are consistenly in the same place in all 2500 files, but in the middle of the data. Following is an example:
<html>
<head>
<title>Title here</title>
<meta name="XYZ" content="Something here...">
<h3> Blah blah</h3> <p>More blah blah</p>
<meta name="123" content="More somthing here">
<meta name="456" content="More somthing here">
</head>
<body>
</body>
</html>
Again, I can find the block using a regular expression <h3>(.*?)</p>, but dont know what to do after that.
I've been told that perl or grep might do the needed task, but that requires outside resources and I have no budget for that.
Any suggestions are greatly appreciated.
thanks,
Rick
-
3. Re: How do I move a block of text from within the <head> tag area to within the <body> tag area?
osgood_ May 7, 2012 7:00 AM (in response to RickEEE)As Rik says why not just do a find and replace?
First find <h3> Blah blah</h3> <p>More blah blah</p> and replace it with nothing.
Then find:
<body> and replace it with <body><h3> Blah blah</h3> <p>More blah blah</p>
-
4. Re: How do I move a block of text from within the <head> tag area to within the <body> tag area?
David_Powers May 7, 2012 7:12 AM (in response to RickEEE)You need to create a regular expression to capture not only the value you want to move, but also the rest of the <head> section. You can then use the captured values in the Replace field.
However, the big question is where does the text need to go in the body? If it's straight after the opening <body> tag, it should be relatively easy. If it needs to go elsewhere, it could be quite complex.
-
5. Re: How do I move a block of text from within the <head> tag area to within the <body> tag area?
RickEEE May 7, 2012 7:30 AM (in response to osgood_)Osgood,
your suggestion would work if the <h3> and <p> text were consistently the same verbiage. They are not. Thanks, though.
David_Powers,
thanks for the suggetion. I might be misunderstanding your suggestion, so bear with me on this reply. In my repurposing exercise, I moved all the old <body> data into the <head> area, so <body> is currently empty. I don't understand your suggestion about capturing "the rest of the <head> section." Why would I want to do that? This regex (<h3>(.*?)</p>) captures exactly what I want to move into the <body>. If there was some way to temporarily store that data as a variable, delete it from the <head>, then recall it during the replace, that would be ideal. Something like this:
- Find <h3>(.*?)</p>
- Store as a variable $1
- Delete <h3>(.*?)</p>
- Find <body>
- Replace <body> $1
The store as a variable $1 part is what I'm missing... not sure how to do that. Thanks for your suggestions.
-
6. Re: How do I move a block of text from within the <head> tag area to within the <body> tag area?
osgood_ May 7, 2012 7:31 AM (in response to RickEEE)RickEEE wrote:
Osgood,
your suggestion would work if the <h3> and <p> text were consistently the same verbiage. They are not. Thanks, though.
Argh ok. Thought it can't be that difficult.
-
7. Re: How do I move a block of text from within the <head> tag area to within the <body> tag area?
David_Powers May 7, 2012 7:34 AM (in response to David_Powers)If you simply want to move the <h3> and <p> out of the <head> and into the <body>, the following regex will work:
(<h3>[\s\S]*?</p>)([\s\S]*<body>)
In the Replace field, use this:
$2$1
-
8. Re: How do I move a block of text from within the <head> tag area to within the <body> tag area?
David_Powers May 7, 2012 7:39 AM (in response to RickEEE)RickEEE wrote:
The store as a variable $1 part is what I'm missing... not sure how to do that.I posted my suggestion before seeing your reply. Since you understand $1, the meaning of my regex should now become clear.
Basically, what it does is capture the bit that you want as $1, plus the rest of the <head> down to and including the opening <body> tag as $2. It then swaps them around.
-
9. Re: How do I move a block of text from within the <head> tag area to within the <body> tag area?
RickEEE May 7, 2012 9:00 AM (in response to David_Powers)Perfection!! Many sincere thanks.
-
10. Re: How do I move a block of text from within the <head> tag area to within the <body> tag area?
David_Powers May 7, 2012 9:18 AM (in response to RickEEE)You're welcome. A lot easier than editing 2,500 files by hand.



