Using HomeSite
|
|
Using Web Development Languages
|
Preserving Code Formats with CodeSweepers
The CodeSweeper feature automates the task of getting your code properly formatted. It can be useful in a number of situations:
- You can enforce coding styles for multiple developers by having them set the same Codesweeper options
- You can clean up the code formatting of an existing project as you review its documents
- You can apply formatting rules after using a visual editor such as Dreamweaver.
Selecting a CodeSweeper
HomeSite includes a number of CodeSweepers, configured for specific types of development. You can also create your own CodeSweepers or edit existing ones.
Macromedia CodeSweepers
There are CodeSweepers tailored to HTML only, HTML/CFML, JSP, Web-XML, and watch. My CodeSweeper is useful for testing and editing, and Macromedia Default HTML Tidy Settings is a pre-configured HTML Tidy for basic code preservation.
For information about formatting your documents to be XHTML-compliant, go to the Macromedia Developer Center for an article called An XHTML-Aware Editor, and read the section entitled An XHTML CodeSweeper.
HTML Tidy
HTML Tidy is an independent open source code utility for verifying and formatting HTML code. Developed by Dave Ragget under the auspices of the W3C, HTML Tidy is installed as an alternative to the Macromedia CodeSweepers. HTML Tidy provides a number of useful features for line wrapping, tag conversions, language support, working in XML, and other features not available in the Macromedia CodeSweepers.
Select Options > Settings > CodeSweeper and expand HTML Tidy CodeSweepers to view and set options.
You can easily update the HTML Tidy engine if new features are added to HTML Tidy between HomeSite releases.
To install a newer version of HTML Tidy:
- Click the link at the top of the HTML Tidy Settings pane.
- On the HTML Tidy Web site, download the latest version.
- Close HomeSite.
- Copy the tidy.exe files to your HomeSite root directory.
- Restart HomeSite.
Your HTML Tidy configuration is not affected by the update.
Running a CodeSweeper
Select Tools > CodeSweeper, then select a CodeSweeper from the dropdown list.
To set the default CodeSweeper:
- Open Options > Settings > CodeSweeper.
- Highlight a CodeSweeper entry in the list and click the Set as Default button.
- Click Apply.
Managing CodeSweepers
You can create new CodeSweepers, edit existing ones, and remove them as needed.
To add a new CodeSweeper:
- Select Options > Settings > CodeSweeper.
- Click New Profile.
- Enter a name for the CodeSweeper and select its type-either Macromedia CodeSweeper or HTML Tidy CodeSweeper.
- Click OK to add it to the list.
- Create a custom profile for it, following the steps in the next procedure for editing a CodeSweeper.
- When you are done, click Apply.
To edit a CodeSweeper:
- Select Options > Settings > CodeSweeper.
- Highlight a CodeSweeper in the list and click the Edit Profile button.
- Make changes to the General and Tag Specific options as necessary.
- When you are done, click Apply.
To delete a CodeSweeper:
- Select Options > Settings > CodeSweeper.
- Highlight the CodeSweeper to delete and click Remove CodeSweeper.
- Click Apply.
Setting Macromedia CodeSweeper options
The options described in this section apply only to Macromedia CodeSweepers. HTML Tidy options are covered in the next section.
To view or edit CodeSweeper options:
- Select Options > Settings > CodeSweeper.
General options
Following are the general options you can set:
- Set the case for tag, attribute, and event names. You can select to preserve the case as it is found in the document or change to all upper or all lower case. Event names for case-sensitive JavaScript event handler can also be set to mixed case.
Tip You can also change the case of tags on demand for the current document, by selecting Edit > Convert Tag Case. This operation cannot be undone.
|
- Set the use of quotes for attribute values.
- The Trim white space between tags option deletes extra spacing produced by some code generation tools. It is enabled by default. For best results, leave it on and disable it for individual tags as needed.
- Select Run in "silent mode" to eliminate the display of alerts the CodeSweeper generates while it is running. You can use this option to run a CodeSweeper in an unattended situation.
- Select Write Errors to a Log File to capture any errors found by the CodeSweeper. You can specify a custom location for the log file.
Macromedia CodeSweepers treat the colon character (:) in tag names as a normal character, allowing the processing of XML namespaces in tags such as <xsl:thistag name="foo"/>
.
Tag-specific options
A wide range of options is available for the individual tags contained in a Macromedia CodeSweeper.
These options cover spacing and indenting and allow you to leave the selected tag unchanged when invoking the CodeSweeper. If you encounter problems parsing server-based script code, try enabling the Preserve tag formatting option.
The Strip tag from document option is especially handy for getting rid of superfluous and unwanted tags that are inserted by code generation tools.
To set rules for a tag:
- Select Options > Settings > CodeSweeper.
- Select a CodeSweeper from the list.
- Edit the General Settings tab as needed.
- Switch to the Tag Specific Settings tab and highlight a tag name in the list.
Note that if you select "All Other Tags" in the list, the rules you select on this tab will apply to every tag that is not in the list but is found in a document.
- If the tag you need is not in the list, click Add Tag, type the tag name, and click OK.
- Edit the options for the tag.
- Click Update Tag.
- If you are done setting options, click Apply.
To remove a tag:
- Select Options > Settings > CodeSweeper.
- Highlight the tag to remove and click Remove Tag.
- If you are done setting options, click Apply.
Setting HTML Tidy options
Following are brief instructions for adding or editing an HTML Tidy profile. For more information, please see the HTML Tidy Web site at www.w3.org/People/Raggett/tidy/. You can access this Web site from the HTML Tidy Settings pane.
Adding a profile
Creating a custom HTML Tidy profile is much like creating one for a Macromedia CodeSweeper.
To create an HTML Tidy profile:
- Select Options > Settings > CodeSweeper.
- Click New Profile.
- Enter a profile name.
- Select HTML Tidy CodeSweeper from the drop-down type list and click OK.
A set of options is already selected by default.
- Highlight the CodeSweeper in the list and click Edit Profile.
- Change the options as necessary.
- When you are done, click Apply.
Editing a profile
The HTML Tidy CodeSweepers pane gives you access to all the supported options, but you can also edit a profile directly. This can be useful in a couple of situations:
- If you want to remove an option from the Settings pane so that it does not display, delete it from the TDY file.
- If you download a newer HTML Tidy version and want to enable new options, add the syntax to the TDY file, as described in the next procedure for editing an HTML Tidy profile. The HTML Tidy Web site lists new features and the correct syntax for enabling them.
To edit an HTML Tidy profile:
- Open the TDY file (a text file) from the \Extensions\Codesweepers directory.
- Save a backup copy of the file before making any changes.
- Edit the name:value pairs as needed.
- Save the file.
The changes are reflected in the HTML Tidy CodeSweeper pane.
To remove an HTML Tidy profile:
- Delete the profile's TDY file from \Extensions\Codesweepers in the Files tab or in Windows Explorer.
Copyright © 2001, Macromedia Inc. All rights reserved. |
|
Comments