Navigation:  Basic Working Procedures > Text Formatting and Styles >

Formatting program source code

Print this Topic Previous pageReturn to chapter overviewNext page
Show/Hide Hidden Text

Examples of program source code are much easier to read if reserved words, comments, identifiers and so on are highlighted as they are in a modern programming editor. Help & Manual's Syntax Highlighting function does this for you. It understands the syntax of Pascal, C++, C#, Visual Basic, ANSI SQL and Visual Objects. It knows the reserved words  of these languages and can distinguish between plain text, comments, strings, numbers and even compiler directives, where they are supported. You can also add your own reserved words.

How to format program code
1.Paste your program code into your topic and select it.
2.Select the Syntax Highlighter tool in Write > Font then select the language parser you want to use from the list displayed.

Once you have chosen a language parser it is set as the default until you select a different language. You can then select it directly by clicking on the Syntax Highlighter tool in the Ribbon.

Editing the syntax highlighting style

The syntax highlighter uses a standard style called Code Example for the font and paragraph attributes. By default this style is set to Courier New, 8 points, no word wrap and keep paragraph lines together.

You cannot delete or rename this style but you can edit it. Just position the cursor in a piece of text formatted with the syntax highlighter and select Styles > Edit Styles in the Write tab to open the style editing dialog with the Code Example style selected. See Editing styles for details.

Indenting with leading spaces/blanks

Program code is often automatically indented with leading spaces. To get this to display correctly you just need to turn word wrap off in the paragraph settings of your code examples, either manually or with a style. Then all the spaces will be converted to   hard space entities which will render correctly in all browsers. Paragraphs will not wrap, but you don't want paragraphs to wrap in program code.

In paragraphs with word wrap turned on Help & Manual converts multiple spaces to alternating soft and hard space characters otherwise browsers would interpret multiple spaces as a single space. However, this will often not render quite right because different browsers interpret the width of these hard/soft space combinations in different ways.

Customizing the syntax highlighter
Click on the drop-down arrow next to in Write > Font, then select Customize.

Font color and style:

You can define the font style and color for the supported elements for each language parser. To change the standard syntax highlighting font face click on Edit Style and edit the Code Example style that is used automatically by the syntax highlighter (see above).

Loading your own reserved words:

You can add your own reserved words to the lists used by the syntax highlighter or completely replace the highlighter's lists with your own lists:

1.Create a plain text file containing your reserved words, with one word on each line.
2.Select the button in the Load reserved words from file: field and select your reserved words text file.
3.Select Add list to predefined reserved words to merge your list of words with the syntax highlighter's list for the current programming language. Deselect this option to replace the highlighter's list with your list.

Restoring the default settings:

Clicking on Reset Defaults restores all the syntax highlighter's settings for the current language to Help & Manual's default values, including the list of reserved words.

See also:

Editing styles

 


Page url: http://www.helpandmanual.com/help/index.html?hm_working_formatting_syntax.htm