18.3 Code Format PreferencesThe Preferences dialog box's Code Format category sets the code formatting options for the HTML code visible in Code view (View Code View) and the Code Inspector. The preferences determine the formatting applied to new documents and additions to existing documents. Existing documents, including documents created outside Dreamweaver, can be reformatted by using the Commands Apply Source Formatting menu command. Beyond the options available in the Dreamweaver preferences, HTML source formatting is controlled by the SourceFormat.txt file in the Dreameaver4/Configuration folder as described in the next section. The following preferences can be set in the Code Format preferences:
18.3.1 The SourceFormat.txt FileThe SourceFormat.txt file, found in the Dreameaver4/Configuration folder, offers more control over HTML source code formatting than Dreamweaver's preferences afford. You can edit this file in a text editor, but you must restart Dreamweaver for the changes to take effect. There are three sections to the SourceFormat.txt file as indicated by the <?options>, <?elements>, and <?attributes> tags (the <?end> tag terminates the file). 18.3.1.1 <?options>The <?options> section corresponds roughly to the options available in the Code Format preferences dialog box. The indentation settings are as follows (note that the tag is spelled "indention," not "indentation"): <indention enable indent="2" tabs="4" use="spaces" active="1,2"> The <indention> tag's enable, indent, tabs, and use attributes correspond to the Indent, Indent Size, Tab Size, and Use fields respectively in the Code Format preferences. The active attribute defines the groups of tags to be indented. Indentation group numbers are specified by assigning a value to the igroup attribute, such igroup="1" or igroup="2". Two predefined groups correspond to the Table Rows and Columns (group 1) and the Frames and Framesets (group 2) options in the Code Format preferences. The <?options> section configures other options as follows: <lines autowrap column="76" break="CRLF"> <omit options="0"> <element case="lower"> <attribute case="lower"> <colors text="0x00000000" tag="0x00000000" unknowntag="0x00000000" comment="0x00000000" invalid="0x00000000" object="0x00000000"> <directives break="1,0,0,1"> <directives delimiter="%3C%25=" break="0,0,0,0"> The <lines> tag's autowrap, column, and break attributes correspond to the Automatic Wrapping, After Column, and Line Break preferences. The <omit> tag is reserved for future use. The case attribute of the <element> and <attribute> tags corresponds to the Case for Tags and Case for Attributes preferences. The <colors> tag corresponds to the Code Color preferences cited in Table 18-1. The <directives> tag controls the formatting of third-party tags. 18.3.1.2 <?elements> and <?attributes>The <?elements> section of the SourceFormat.txt file defines formatting preferences for individual tags. For example, this line defines the formatting attributes of the <p> tag. <p break="1,0,0,1" indent> The four numbers following the break attribute indicate the number of line breaks to insert before the opening tag, after the opening tag, before the closing tag, and after the closing tag. The indent attribute tells Dreamweaver to indent this tag according to the settings in the <?options> section. These two lines assign the <td> and <frameset> tags to indention groups 1 and 2 using the igroup attribute: <td break="1,0,0,1" indent igroup="1"> <frameset break="1,0,0,1" indent igroup="2"> The noformat attribute prevents Dreamweaver from changing the format of the tag contents, as is the case with the <pre> tag: <pre break="1,0,0,1" noformat> The <?attributes> section of the SourceFormat.txt file defines custom capitalization for the specified HTML attributes. The namecase attribute specifies the exact case to use for this particular element, which is important because JavaScript is case-sensitive. The following line ensures the correct case for onMouseOver: <onMouseOver namecase="onMouseOver"> The sameCase attribute forces the value of an attribute to be capitalized in the same way as the attribute name: <align samecase> The sameCase attribute is also used for Boolean attributes, which don't have values, and should not be removed. <checked samecase> See the comments within the SourceFormat.txt file itself for more information about its format. Search for "Changing default HTML formatting" under Help Using Dreamweaver (F1) for more information. |