That’s right, get your bootstraps laced up and put your helmets on — we are marching onward, a mission to search out the rogue code in all your directories, folders, files, documents, and web pages. Okay, maybe not all of your code has rascally elements, tags, or attributes, but when was the last time you checked your directories for files containing outdated code? Maybe you have deprecated code. Remember the HTML 4.01 specification put forth by the W3C? Maybe you have code that needs to be replaced and revisions have been put on the back burner. Or maybe you have redundant, outdated, or trivial content, and it needs to be scoured and removed.
Finding and replacing large amounts of code takes some work, and you can manually streamline the purging or replacing of this code faster with these quick steps using Dreamweaver. Our weapon of choice, the Find and Replace Strip Tag.
A word of caution: Whatever your sandbox, make sure you play nice; so before you start with replacing or deleting any code in your directories, documents, and files, you will want to make sure they are backed up on a development server, or copied from your production or staging environments to a local non-published drive or directory. Preparation before the mission is important!
1. Open Dreamweaver.
2. From the Edit menu select Find and Replace (CTRL+F) (Figure A ).
3. The default Find and Replace dialog box opens and there are several options. The simplest is finding within the current document any source code with the usual find and replace options. But what if you want to search more than one document, or how about code that has attributes also? You want to get rid of all that code, not just the <font> element, for example, but all the associated attributes along with the code. The Find In: options include the default Current Document, Selected Text, Open Documents, Folder…, Selected Files in Site, and Entire Current Local Site. These options provide the ability to scour from the single document level to the entire site level, a broad range of choices.
4. Let’s say we want to search for deprecated code that references the <font> tag and any references to it with attributes as well. Instead of just a single document, I want to search the entire site for any occurrence with the <font> tag. Before I start this process, I am going to copy my suspicious documents to a new folder and name it Suspects. Straight-forward, right? We are on a mission, remember! You can organize the suspect files and directories depending on your situation, as long as you remember where they are to be returned after stripping out or replacing the code.
5. We will select the Folder… option in the Find In drop-down menu, since I’ve gone the route of rounding up all the dubious documents, shown in Figure B. Then, click the Choose Folder Search icon and browse to the Suspect folder and click Select. It’s the little folder icon just to the right of the text field.
6. In the Search for drop-down menus select Specific Tag, and then Font as show in Figure C.
7. Then, click the minus (-) button to remove the With Attribute filter control. This will broaden the scope of the operation to eliminate all instances of the <font> tag, regardless of whether attributes are present or not (e.g., both <font face=”Arial”> and <font face=”Arial” color=”#FFFFCC”> will be eliminated). This is necessary because a <font> tag with attributes is still a <font> tag. Make sure Strip Tag is the Action setting in the drop-down menu and that the Ignore Whitespace option is checked; this ensures that once you execute the procedure that all instances of the code are captured, displayed in Figure D.
8. Now we are ready to perform the mission — clicking on the Replace All button will remove all instances of the <font> tag from every document in the source folder. Dreamweaver will confirm your intention, so we will click Yes, and the task will begin processing all documents, shown in Figure E.
9. The resulting modifications will be displayed at the bottom of the screen, seen in Figure F.
10. All the document files will be stripped of “all” <font> tags and automatically saved once the process is completed.
Once you get comfortable using the Strip Tag feature in Find and Replace, you will want to expand, using and stripping other tags and content from entire local sites.