mlreportgen.dom.WhiteSpace Class
Namespace: mlreportgen.dom
White space type
Description
Specifies behavior for white space and line breaks in text.
The mlreportgen.dom.WhiteSpace
class is a handle
class.
Creation
Description
Input Arguments
option
— White space behavior
'normal'
| 'nowrap'
| 'pre'
| 'pre-line'
| 'preserve'
| 'pre-wrap'
White space behavior, specified as one of these values.
Note
Only 'preserve'
and 'normal'
affect Word
output.
Value | Description |
---|---|
| For HTML and PDF, removes leading and trailing spaces and collapses multiple spaces within text to a single space, ignoring line breaks. For Word, removes leading and trailing spaces, ignoring line breaks. |
| Sequences of white spaces collapse into a single white space. Text
does not wrap to the next line. The text continues on the same line until a
|
| Preserves white space. Text wraps only on line breaks. Acts like
the |
| Preserves spaces and line breaks. |
| Sequences of white spaces collapses into a single white space. Text wraps when necessary and on line breaks. |
| Preserves white space. Text wraps when necessary and on line breaks. |
Properties
WhiteSpace
— How to treat white space in text
[]
(default) | "normal"
| "nowrap"
| ...
How to treat white space and line breaks in text, specified as one of the values in this table.
Value | Description | Supported Output Types |
---|---|---|
| For HTML and PDF, this value removes spaces at the beginning and the end of text. Multiple spaces in the text collapse to a single space. For Microsoft® Word, this value removes spaces at the beginning and end of text. | All |
| Sequences of white space collapse into a single white space. Text never wraps to the next line. | HTML |
| Preserves white space. Text wraps only on line breaks. Acts
like the | HTML and PDF |
| Same as "pre". | All |
| Sequences of white space collapse into a single white space. Text wraps when necessary and on line breaks. | HTML and PDF |
| Preserves white space. Text wraps when necessary and on line breaks. | HTML and PDF |
Note
Setting the WhiteSpace
property adds a corresponding mlreportgen.dom.WhiteSpace
format
object to the Style
property. Setting the
WhiteSpace
property to an empty value removes the
object.
Data Types: char
| string
Tag
— Tag for mlreportgen.dom.WhiteSpace
object
character vector | string scalar
Tag for the mlreportgen.dom.WhiteSpace
object, specified as a character vector or
string scalar. The DOM API generates a session-unique tag as part of the creation of
this object. The generated tag has the form
CLASS:ID
, where
CLASS
is the object class and
ID
is the value of the
Id
property of the object. Specify your own tag value to help
you identify where to look when an issue occurs during document generation.
Attributes:
NonCopyable | true |
Data Types: char
| string
Id
— Object identifier for mlreportgen.dom.WhiteSpace
object
character vector | string scalar
Object identifier for the mlreportgen.dom.WhiteSpace
object, specified as a
character vector or string scalar. The DOM API generates a session-unique identifier
when it creates the document element object. You can specify your own value for
Id
.
Attributes:
NonCopyable | true |
Data Types: char
| string
Examples
Preserve Space After Colon
This example shows the effect of using the 'preserve'
option for each of the output formats. Preserving the trailing space is useful, for example, when you are creating a chapter title. Typically, you append an autonumber after the text 'Chapter: '
. Using 'preserve'
keeps the trailing space.
HTML Output
When you choose HTML as the output format, the multiple spaces collapse but the trailing space is preserved.
import mlreportgen.dom.*; doctype = 'html'; d = Document('testHTML',doctype); open(d); p = Paragraph('This paragraph has extra spaces and one after the colon: '); % p.Style = {WhiteSpace('preserve')}; append(p,'XX'); append(d,p); close(d); rptview(d.OutputPath);
Word Output
When you choose Word as the output format, the multiple spaces do not collapse and the trailing space is preserved. Try commenting out the WhiteSpace
property. The multiple spaces are preserved, but the trailing space after the colon is removed.
import mlreportgen.dom.*; doctype = 'docx'; d = Document('test',doctype); open(d); p = Paragraph('This paragraph has extra spaces and one after the colon: '); p.Style = {WhiteSpace('preserve')}; append(p,'XX'); append(d,p); close(d); rptview(d.OutputPath);
PDF Output
Description of second code block
import mlreportgen.dom.*; doctype = 'pdf'; d = Document('test',doctype); open(d); p = Paragraph('This paragraph has extra spaces and one after the colon: '); p.Style = {WhiteSpace('preserve')}; append(p,'XX'); append(d,p); close(d); rptview(d.OutputPath);
Version History
Introduced in R2014b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)