98. toggleTextStyle
Prev | Chapter 6. Commands written in the Java™ programming language | Next

## 98. toggleTextStyle

Parameter syntax:

    name [ '[@' attr_name [ '=' quoted_attr_value ]? ']' ]?

This command emulates the behavior of the Bold, Italic, Underline, etc, toggles found in the tool bars of almost all word-processors. Such toggles add a given text style to text spans not having this text style and remove a given text style to text spans already having this text style. Hence the name “text style” toggle.

Note that such toggles do not require some text to be explicitly selected. If the caret is in the middle of a word, then the toggle acts on this word. If the caret is before or after a word, the toggle acts on this text location by inserting an empty text span having or on the contrary, not having, the corresponding text style.

This command supports the node selection in addition to the text selection. For example, if you want to apply a “text style” to an element in its entirety, suffice to explicitly select it. This is more handy that selecting all the text this element contains.

`name`

  Name of an element which behaves like a text style. Such elements must have a mixed content and may contain text as well as other text styles in arbitrary order and number of occurrences.

  DocBook 4 example:

      literal

  Equivalent DocBook 5 example:

      {http://docbook.org/ns/docbook}literal

`attr_name`

  An element which behaves like a text style may have at most one required attribute. When this is the case, this attribute must be specified in the parameter of the `toggleTextStyle` command.

  DocBook 4 example:

      ulink[@url]

  Equivalent DocBook 5 example:

      {http://docbook.org/ns/docbook}link[@{http://www.w3.org/1999/xlink}href]

`quoted_attr_value`

  In some cases, an element which behaves like a text style has an attribute which specifies a given style. When this is the case, this attribute and its specific value must be specified in the parameter of the `toggleTextStyle` command.

  DocBook 4 example:

      emphasis[@role='bold']

  Equivalent DocBook 5 example:

      {http://docbook.org/ns/docbook}emphasis[@role='bold']

Notice in the above examples that all XML names are specified using the Clark's notation.

Prev | Up | Next
97. toggleCollapsed | Home | 99. undo