Creates a split strategy.
The defaults are a header level of 2, frontmatter preserved in the original file, and the {title} filename pattern. Any supplied option overrides its default.
Options that override the defaults.
ProtectedoptionsThe effective options for this strategy: the supplied options layered over the defaults set in the constructor.
ProtectedextractSeparates a leading frontmatter block from the rest of the content.
The full file content.
The split content.
The content following the frontmatter, or the whole input when there is none.
The leading --- delimited block including its delimiters, or an empty string when there is none.
ProtectedextractExtracts the title text from a header line.
A markdown header line.
The text after the # markers, trimmed.
ProtectedgenerateGenerates a filename for a section from the filenamePattern option.
{title} is replaced by the sanitised title (or section-N when that is empty), {index} by the one-based index and {original} by the original filename without its extension. The original file's extension is appended, defaulting to .md.
The section title.
The zero-based position of the section.
The name of the file being split.
The generated filename.
ProtectedgetReturns the header level of a line.
The line to inspect.
The number of leading # characters when the line is a header (the markers followed by whitespace or the end of the line), otherwise 0.
ProtectedisChecks whether a line is a header of exactly the given level.
The line to inspect.
The header level to match.
True when the line's header level equals targetLevel; headers of other levels do not match.
ProtectedsanitizeConverts a string into a filename-safe slug.
The text is lower-cased, characters other than letters, digits, spaces and hyphens are removed, whitespace becomes hyphens, repeated and surrounding hyphens are collapsed, and the result is limited to 50 characters.
The text to convert.
The slug, which may be empty.
Splits at lines that contain one of the splitMarkers (default <!-- split --> and ---split---).
The marker lines are dropped and the text between them becomes the sections, including the text before the first marker and after the last. A section is titled by its first header, otherwise by its first line of text (limited to 50 characters) that is not a comment or rule, otherwise Section N. When no marker is found a warning is added, no sections are returned, and the whole original content is returned as remaining content.
The full content of the file to split, including any frontmatter.
The name of the file being split, used when generating section filenames.
The sections, with the frontmatter as remaining content when preserveFrontmatter is on.
Protected StaticnumberReturns value unless it is nullish or zero, in which case fallback is used, since zero is not a
meaningful value for these options (header levels start at 1, size limits must be positive).
Protected StaticstringReturns value unless it is nullish or the empty string, in which case fallback is used,
an empty string is treated as "no value supplied" rather than a meaningful value to preserve.
Split strategy that divides content at manually specified markers.
Looks for specific comment markers or text patterns in the content to determine split points. This provides precise control over where splits occur, regardless of content structure.
Example
Manual marker splitting