Function s = textblockbreak(s)
s = textblockbreak(s,opt)
breaks each individual line in the given string at word
boundaries, and returns the resulting string.
The input argument s is a character row vector or a
cell-array of character row vectors. The output argument
will have the same form as the input argument s.
The optional input arugment opt is a struct or a row
cell-array of key-value pairs. Below, settings are
indicated by opt as a struct, and the default value of
each field are given too:
opt.maxwidth1 = 20;
opt.maxwidth1 indicates the maximal number of
characters on the first line.
opt.maxwidth2 = 20;
opt.maxwidth2 indicates the maximal number of
characters on the second or a following line.
opt.linedelim = "\n";
opt.linedelim contains the line delimiter, i.e. the
character by which lines are separated within a
string.
opt.worddelim = " ";
opt.worddelim contains the word delimiter, i.e. the
character by which words are separated within a line.
opt.wordbreaking = 1;
If opt.wordbreaking is one, a special minimalistic
word-breaking mode is applied. In that case, only
words which are longer than the line width
opt.maxwidth1 or opt.maxwidth2, are broken. The
position of the breaking within a word is purely
determined by counting characters, and not by applying
the correct hyphenation rules.
If opt.wordbreaking is not one, no word-breaking is
applied at all.
opt.hyphen = "βΈ—";
opt.hyphen contains the character which is put at the
end of the line when a word is broken.
The default character is U+2E17, a "double oblique
hyphen" from the Unicode "Supplemental Punctuation"
block:
https://en.wikipedia.org/wiki/Supplemental_Punctuation
https://en.wikipedia.org/wiki/Double_hyphen
opt.nminchunk = 3;
opt.nminchunk indicates the minimal number of
characters of a part of a broken word. Its value
should be (much) larger than the number of characters
of opt.hyphen plus the maximal number of characters on
the line. This condition is not checked!
The function takes care of the utf-8 encoding of strings,
and accounts for the real number of characters instead of
simply counting the number of bytes in a string.
The function internally calls the following non-standard
m-files:
-- kvpairs2struct.m
-- unicodelength.m
(c) 2026 fabien van mook
2026.08.20 release of this file within package "fvm-textblock" under GNU GPLv3+