<preformat>
Summary
Used for blocks of computer source code typically with a monospaced font.
This element replaces PS Standard’s block level <code> element to avoid confusion with HTML inline <code> elements.
Usage context
| Element category | block |
|---|---|
| PSML level | portable |
| Permitted content | text only* |
| Permitted parent | <fragment> <item> <block> <cell> |
| HTML equivalent | <pre> |
| OpenXML equivalent |
* This element can also contain character-style elements, however, if the content is edited in CK, extra line-breaks are often inserted before these elements. So it is safer to avoid them.
Attributes
This element includes the following attributes:
| Name | Type | Required | Description |
|---|---|---|---|
| role | role | no | Custom value that can be used for formatting |
@role
A role for the preformatted text which can be used for formatting.
Examples
Plain text
Preformatted plain text to preserve whitespace.
<preformat> Yet do I fear thy nature; It is too full o' the milk of human kindness To catch the nearest way.</preformat>
Code sample
A preformatted code sample.
<preformat role="lang-javascript">function () {
return "Hello!";
}</preformat>
It is good practice to specify the language of code samples. Use the role attribute to specify the language. A common convention adopted by syntax highlighter is to prefix the language name by lang- or language-. In the preceding example, we've used lang-javascript.
Schema
XML Schema
<xs:element name="preformat">
<xs:complexType mixed="true">
<xs:group ref="character-style-group"
minOccurs="0"
maxOccurs="unbounded" />
<xs:attribute name="role" type="role"/>
</xs:complexType>
</xs:element>
Relax Schema
element preformat {
attribute role { role }?,
character-style
}
Compatibility
This element was introduced in the first draft of PSML and is well-supported from PageSeeder 5.1.