pre (text format)
Import from: CURL.GUI.STANDARD. Defined in package CURL.GUI.TEXT-FORMATS.
Based on: paragraph
With keyword defaults set to: _style-element="pre",font-family="monospace",

Displays the paragraph contents in a monospace font, preserving whitespace and newlines.

Syntax

{pre
        [option1=value1,
         option*=value*,]
          ...}
            
option: Any paragraph or character option.
value: A valid value for the option.
...: The contents.

Paragraph Options

The following are paragraph options, which directly affect pre and other paragraph formats. All paragraph options are local.

Character Options

If you set character options on paragraph, they apply to all text in the paragraph. If the paragraph does not contain text, the option settings have no effect. Note that character options are, unlike paragraph options, nonlocal.

Description

This paragraph format is identical to:

{paragraph font-family="monospace",
      text-preserve-whitespace?=true, ...}


pre formats its contents in a monospace font, to preserve character alignment between lines. However, because it is a paragraph format, you can set any character or paragraph option in it, including resetting the font-family option to a different font face.

Although pre preserves whitespace and newlines in a paragraph, you should remember that it is a paragraph format, and, like all paragraph formats, deals with whitespace and newlines differently at the start and the end of the paragraph. The following describes how these special lines are handled. Note that, to distinguish between the lines you code and its resulting presentation, the following description use coding line to describe a source line; and display line to describe a line as presented in the browser.

Example

Compare the following paragraphs in the example. The paragraph in the middle does not display its first coding line because it does not contain any non-whitespace characters. (The comment is ignored.)
Example
{pre color="green", font-style="italic",       1st coding line
     2nd coding line
     Last coding line}Outside the paragraph
{pre color="teal",
    font-style="italic",    || 1st coding line
     2nd coding line
     Last coding line}
Outside the paragraph
{pre 1st coding line
     2nd coding line
            Last coding line}Outside the paragraph



The next example uses verbatim strings within pre. It allows you to describe curl code in pre, ensuring that the code does not get evaluated. Recall that the syntax for verbatim strings is:
|" content "|



Example
{pre
|"   When you use {Graphic.draw},
   remember you can even render a straw.
   Hark! Art thou a bore?
                    -K.R."|}


It is tempting, perhaps, to put the verbatim string marker on the first coding line. However, this makes the first newline part of the contents, which is usually not the desired behavior.


Example
|| Don't do this!
{pre |"
   When you use {Graphic.draw},
   remember you can even render a straw.
   Hark! Art thou a bore?
                    -K.R."|}


If you choose to put content in the first coding line, remember that, to produce the first display line, all whitespace preceding the content will be stripped.


Example
{pre |"   When you use {Graphic.draw},
   remember you can even render a straw.
   Hark! Art thou a bore?
                    -K.R."|}
    

Notes

The Curl parsing rules apply to all text formats. This is worth a reminder when embedding a text format within pre because, as shown below, the newline after {bold is stripped, resulting in a single display line.
Example
{pre
Don't break up the embedded format {bold
here}, thinking you'll get two display lines.}

{pre
Create the newline outside the
{bold embedded format} instead.}


When the text-breakable? option is false, such as when using the no-break text format or in the labels of certain controls, newlines are treated as whitespace but not treated as line breaking characters.