Operator Type:
Operator Scope of Action:
Operator Purpose:
Data Type Returned:
Operator First Added:
Operator in Current Baseline:
Operator Last Altered:
Function [other Function type actions]
Item [operators of similar scope]
Data manipulation [other Data manipulation operators]
String [about String data type]
v5.8.0
Baseline
As at baseline
String.paragraphs(parasNum)
This function extracts the first parasNum paragraphs of the referenced string or String-type attribute. Examples:
$MyString = "Paragraph 1\nParagraph 2".paragraphs(1);
In the example the "\n" simulates a line break. The code would set $MyString to the string "Paragraph 1". A more real example:
$Text = $Text("Some note").paragraphs(2);
In the second example the current note's $Text would be set to the first 2 paragraphs of note "Some note".
To get a single given paragraph of a multi line/paragraph string, such as $Text, see String.split() (beware of semicolons in the source string being misinterpreted as list item delimiters, as discussed in that article).
This function respects existing rich text styling.
To get all paragraphs as a list, e.g. in order to iterate against them using list.each(), then use string.split(), e.g.:
$MyList = $Text.split("\n+");
Or from a different note, e.g. 'another note':
$MyList = $Text("another note").split("\n+");
The \n+
implies to split on and remove sub-strings of one or more consecutive line breaks, thus avoiding the creation of unwanted creating blank list items in the output where there are several line breaks between paragraphs.
Working with styled text
This operator is capable of worthing with StyledString operators: StyledString.bold, StyledString.fontSize(), StyledString.italic and StyledString.strike.
See also—notes linking to here: