Split a Markdown file (or any kind of plain-text file) in sections marked by the § character.
npm install markdown-split
let split = require('markdown-split');
let content = `
§ First section
Content of the first section.
§ Second section
Content of the second section.
`;
let sections = split(content);
console.log(sections);
This should produce the following output:
[
{
name: 'First section',
content: 'Content of the first section'
},
{
name: 'Second section',
content: 'Content of the second section'
}
]
If the § character is not followed by a section name, the name
property of that section will not be present in the output.
If you don't already have it on your keyboard, this Wikipedia page lists the key combinations to produce the § character on a variety of keyboards.