Function s = textblockprepend(s)
s = textblockprepend(s,opt)
prepends and appends each given line in the given string,
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.pre1 = "_";
opt.pre1 contains the string to be prepended on the
first line.
opt.pre2 = "_";
opt.pre2 contains the string to be prepended on a
second and following line.
opt.post = "_";
opt.post contains the string to be appended on each
line.
opt.linenofrmt = "%02d";
opt.linenofrmt contains the sprintf template to
convert the line number to a string which is prepended
to each respective line (before opt.pre1 or opt.pre2).
opt.linedelim = "\n";
opt.linedelim contains the line delimiter, i.e. the
character by which lines are separated within a
string.
Contrary to (non-standard) strprefix.m,
textblockprepend.m also applies prepending and appending
to an empty string.
The function internally calls the following non-standard
m-files:
-- kvpairs2struct.m
(c) 2026 fabien van mook
2026.08.20 release of this file within package "fvm-textblock" under GNU GPLv3+