Formatting and Styling Text

VERSION 3 Published

Created on:Oct 23, 2007 9:39 AM by CurlEducation - Last Modified:  Jul 21, 2008 9:48 AM by CurlEducation

Most of the content that exists on the Web is static data. Tons and tons of information can be accessed using your browser. The way this information is presented plays a very important role.

Similar to HTML, Curl has a number of options that are used to enhance the presentability of the information. This includes the use of color, font size, font style, enumerated lists, and so on. The Curl language supports these text elements by providing text formats which can be classified as character formats and paragraph formats.

Formatting Text

Let's modify the applet text by adding simple text formatting. The simplest way to format text is to use Curl's predefined text formats.

Two very common text formats are bold and italic.
  • bold presents the textual content in a bold font face.
  • italic formats the textual content using an italic or oblique font.

Curly braces are used to specify a specific operator that is then followed by the content that it is applied to. We call this a Curly Expression, in which each open curly brace { has a matching closing curly brace } that bounds the {operator operands} expression.

An example is: {bold my text}, where bold is the operator and my text is the operand. In our example code below, we have nested the italic text format inside the bold text format. The result is that the word "first" will be both bold and italic.



Tip: Notice that when we add an operator to the content, the editor automatically color codes it so that it stands out. The color coding of API elements is also available in the Curl IDE.

http://developers.curl.com/wiki/samples/images/note.jpg The above example is similar in functionality of HTML properties. The HTML code tags would resemble the following:




<b><i> This is text that is bold and italic </i></b>

Pre-defined Text Formats

As we stated above, both bold and italic are predefined text formats. These formats are derived form the core Curl text formats and are shortcuts to frequently used text formats. Other Curl predefined text formats include:

  • monospace
  • tiny
  • small
  • big
  • huge
  • quote
  • underline
  • line-through
  • superscript
  • subscript

Using Options

Similar to HTML, formatting text can be specified using properties or options.



{text
   option1=value1,                    
   option2=value2,                
   ...                
 }

Each text format can have zero or more options that are specified in a comma delimited format. In the next example, we will specify the font size and the color of the text using option/value pairs.


http://developers.curl.com/wiki/samples/images/note.jpg Notice how you can mix Curl formatting techniques using option/value pairs and predefined text formats.


http://developers.curl.com/wiki/samples/images/help.jpg For more information regarding text formats, please refer to the following section in the Curl Documentation:Curl Developer's Guide > Getting Started with Text Formats


Formatting a Paragraph

By setting paragraph properties, or options, you control the appearance of the entire paragraph. This includes all contents of the paragraph (text, images, backgrounds, etc.) Each paragraph uses the paragraph text procedure that has the following syntax.



{paragraph                   
 option1=value1,                    
 option2=value2,                
 ...                
 }

List each option and value in any order. Similar to text formatting, a comma is necessary between each option/value pair. The paragraph text is specified last. Notice that each paragraph option specifies a particular characteristic. You can include any number of paragraph options to define a format.



Tip: Option values can be specified using any valid Curl quantity, or unit, such as pt, px, cm, and in.

http://developers.curl.com/wiki/samples/images/help.jpg For more information regarding Curl quantities, please refer to the following section in the Curl Documentation:Curl Developer's Guide > Core Language - Types > Quantities and Units


Indenting, Offsetting, and Spacing

In the following example, we are using paragraph spacing, indenting and offset properties. Obviously you might not use all of the options listed below, however for example purposes, we have listed the most commonly used options.



Notice that all the options that apply only to paragraphs have names that begin with paragraph-. All of these options are local options. That is, if you nest a paragraph within another, or if you place paragraphs in a Graphic, any paragraph option that is set on the container does not pass through to the contained paragraph. This is necessary since paragraph options alter the alignment and indentation of contents in a paragraph. Since paragraphs are often embedded in other paragraphs, and indentation-related options specify relative values, having local paragraph options prevents the possibility of obtaining unanticipated results.

Block Quotes

A block quote is a section of text that is separated from the rest of the text. Block quotes usually appear indented from both sides of a Web page and are often used for displaying long quotations. Block quotes can be defined by specifying the right and left edges, or by using the predefined paragraph format blockquote.



Note that blockquote is a Curl pre-defined format in which {blockquote ...} is equivalent to:



{paragraph
   paragraph-left-indent=8em, 
   paragraph-right-indent=8em,  
 ... }

http://developers.curl.com/wiki/samples/images/help.jpg For more information regarding paragraph formats, please refer to the following section in the Curl Documentation:Curl Developer's Guide > Text Formatting > Paragraph Formats and Options


Formatting Specific Text in a Paragraph

You can control the appearance of text in your document by specifying formatting on specific words or sentences, rather than the entire paragraph. In these cases, the text formatting will override any paragraph settings that are placed.

Each time we specify text formatting, we can use the {text ...} format. Each property/value combination must be delimited with a comma. Alternatively, we can specify predefined text formats such as bold or italic. Notice that predefined character formats can also be nested.



http://developers.curl.com/wiki/samples/images/note.jpg In the above example, we have also included a line break {br}. This is an example of using a character format without content. Other formats like this include: bullet, copyright, degrees, em-dash, en-dash, registered-trademark, and trademark.


http://developers.curl.com/wiki/samples/images/help.jpg For more information regarding character formats, please refer to the following section in the Curl Documentation:Curl Developer's Guide > Text Formatting > Character Formats and Options


Creating Custom Text Formats

When you create multiple documents belonging to the same product, application, book, or company, you are likely to want a common template of formats to ensure a consistent appearance.

To define your own character or paragraph format, you can either build on one of the predefined formats, or you can define your own format. Both ways use define-text-format.



Tip: Consider defining a new text format more closely suited to your purpose. For example, if you're writing a book on insects, you might want both the Latin names and the common names to be italicized, but if you use italic directly, then it would be difficult for you to later change the formatting of the common names.

http://developers.curl.com/wiki/samples/images/help.jpg For more information regarding paragraph formats, please refer to the following section in the Curl Documentation:Curl Developer's Guide > Getting Started with Text Formats > Organizing Text Formats

Average User Rating
(0 ratings)




There are no comments on this document