?
Solved

How to prevent auto-tag-completion on "search and replace" in Dreamweaver MX 2004

Posted on 2006-04-13
6
Medium Priority
?
205 Views
Last Modified: 2010-04-25
I'm using Dreamweaver MX 2004 to update some badly-marked-up HTML documents.  My process is to use the Find/Replace feature to blow through whole directory trees of HTML and fix a few tags and issues at a time.  It works quite well.

There is a particular problem that keeps coming up.  I don't know if it's me, or if it's Dreamweaver.  It would seem that when I attempt to "surround" a particular tag sequence with another tag, I don't get my desired results.  Let me 'splain with an example:

Existing HTML looks like this:

<a name="target">Blah De Blah</a>


What I want the Replace feature to do is this:

<h2><a name="target">Blah De Blah</a></h2>


(I assumed that I would have to do that in TWO steps; using 'Add Before Start Tag', and then 'Add After End Tag' in my search/replace activity).

However, what I get when I search for '<a>' tags with a 'name' attribute of '[any_value]' and tell DW to 'Add a <h2> Before Start Tag' is this:

<h2></h2><a name="target">Blah De Blah</a>

Likewise, if I try 'Add After End Tag', I get:

<a name="target">Blah De Blah</a><h2></h2>

I've tried turning OFF the 'Auto Tag Completion' feature in Edit > Preferences > Code Hints, but that doesn't seem to have an effect on Search/Replace.

Any ideas on how I can fix this?  I can't use a different version of Dreamweaver, and I really can't use another product (corporate bureaucracy at work here).




0
Comment
Question by:mpp1031
  • 3
  • 2
5 Comments
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 375 total points
ID: 16450295
Hi mpp1031,

Two things to try:

1) Go to Edit | Preferences | Code Rewriting and turn off "Fix invalidly nested and unclosed tags"

That may or may not work.  I can't fully replicate what you are seeing in DW 8.  When I tried it, DW closed the h2 tag if it was not in a paragraph tag.  In other words, if the <a> occurred within a <p>, then the <h2> did not close.  When the <a> was not in a <p>, the tag auto-closed when using F/R for specific tags.

Now that I think about it, also check under General for "Switch to plain paragraph after heading" to see if it is enabled or not.  If enabled, try disabling.

2) Don't use tag search to do something that is this simple.

Just search in Source Code for <a and replace it with <h2><a

then

/a> replaced with  /a></h2>

This worked no matter where the <a> was located, unless <a and /a> appear in your content as text (not links).

0
 

Author Comment

by:mpp1031
ID: 16455573
I'm not at work right now, but on Monday I'll try #1.

Problem with your #2 suggestion is that I have *other* <a> tags that *are* links (i.e. with href attributes) that I would not want to enclose in <h2></h2> tags.  I suppose I could try doing a more complex Regular Expression search, but I suck at Regexes, so that's a last resort.
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 16455664
Meh.  Obviously you can start the h2 by searching for <a name= but closing them would be tough.

The better question to be asking here is if MM is going to let you put a new tag in front of or behind a tag, why the heck couldn't they have added a wrap tag option to the F/R function?

I did a little more digging and #1 should work for you.  What appears to be happening is that by using tag F/R, DW is re-validating the code as it goes along.  So by turning off the validation it should be okay.  I'm not at my normal location this week, so I can't test it first :(

The DW regular expressions are not like "normal" regular expressions.  They are a little simpler to define and use and MM devnet has a good tutorial:

http://www.macromedia.com/devnet/dreamweaver/articles/regular_expressions.html

I can't normally write a regex to save my life, but I have been able to write them in DW with only a minimum of pain.  Bonus:  you can save the F/R definitions once you get one that works...
0
 

Author Comment

by:mpp1031
ID: 16469178
I think I've found a compromise *solution* (however "bootleg" it might be):

I do my F/R, but instead of telling DW to replace with <h2>, I specify \h2\ (since backslashes aren't typically used very much in these pages, if at all... I hope), and \/h2\ for the end tag, of course.  It takes me FOUR steps instead of 1 or 2, but it does get my desired result.  I suppose I could use some other character (or cominbation of characters) instead of the backslash.

I'll leave this open, briefly, if anyone else has any comments or a better/different solution...

jason1178, I checked this morning when I got in, and I already had the "Fix nested tags" feature disabled, as well as ALL the code-rewriting options, and it still doesn't work as it *should*.  I even tried turning them back on in various combinations, even specifying that HTM and HTML documents never be rewritten.  DW didn't care.  It insists on throwing the whole tag combination in there, even if I only want the opening tag.  Weird.
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 16470559
I can confirm that it is odd.  I tested it over the weekend and played around with all the various toggles and got the same results.  Again, the only thing I can think of is that when F/R on tags, DW goes into validation mode and closes the tag no matter what you specify.

Oh well.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question