Gathering detailed insights and metrics for section-matter
Gathering detailed insights and metrics for section-matter
Gathering detailed insights and metrics for section-matter
Gathering detailed insights and metrics for section-matter
Like front-matter, but allows multiple sections in a single document.
npm install section-matter
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.4
Supply Chain
99.4
Quality
74.6
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
232,192,617
Last Day
319,865
Last Week
1,742,975
Last Month
7,259,816
Last Year
71,857,040
MIT License
22 Stars
14 Commits
1 Forks
3 Watchers
1 Branches
2 Contributors
Updated on Apr 19, 2024
Minified
Minified + Gzipped
Latest Version
1.0.0
Package Id
section-matter@1.0.0
Size
4.35 kB
NPM Version
5.5.1
Node Version
8.7.0
Published on
Oct 23, 2017
Cumulative downloads
Total Downloads
Last Day
42.8%
319,865
Compared to previous day
Last Week
5.9%
1,742,975
Compared to previous week
Last Month
1.7%
7,259,816
Compared to previous month
Last Year
35.7%
71,857,040
Compared to previous year
2
3
Like front-matter, but supports multiple sections in a document.
Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your :heart: and support.
Install with npm:
1$ npm install --save section-matter
Params
input
{String|Buffer|Object}: If input is an object, it's content
property must be a string or buffer.returns
{Object}: Returns an object with a content
string and an array of sections
objects.Example
1var sections = require('{%= name %}'); 2var result = sections(input, options); 3// { content: 'Content before sections', sections: [] }
See available options.
With the exception of front-matter, which must be the very first thing in the string, the opening delimiter of all other sections must be followed by a string to be used as the key
for the section.
Given the following string:
Content before the sections.
---
More content.
---one
title: One
---
This is the first section.
The following code:
1console.log(sections(input));
Results in:
1{ 2 content: 'Content before the sections.\n\n---\n\nMore content.\n', 3 sections: [ 4 { 5 key: 'one', 6 data: 'title: One', 7 content: '\nThis is the first section.' 8 } 9 ] 10}
Type: function
Default: undefined
Function to be called on each section after it's parsed from the string.
Example
Given the following string (foo.md
):
This is content before the sections.
---one
title: First section
---
This is section one.
---two
title: Second section
---
This is section two.
Using the following custom section_parse
function:
1var fs = require('fs'); 2var path = require('path'); 3var yaml = require('js-yaml'); 4var sections = require('section-matter'); 5 6var str = fs.readFileSync('foo.md'); 7var options = { 8 section_parse: function(section) { 9 console.log(section) 10 section.key = 'section-' + section.key; 11 section.data = yaml.safeLoad(section.data); 12 } 13}; 14 15var result = sections(str, options); 16console.log(result);
Results in:
1{ 2 content: 'This is content before the sections.\n', 3 sections: [ 4 { 5 key: 'section-one', 6 data: { title: 'First section' }, 7 content: '\nThis is section one.\n' 8 }, 9 { 10 key: 'section-two', 11 data: { title: 'Second section' }, 12 content: '\nThis is section two.\n' 13 } 14 ] 15}
Type: string
Default: ---
Delimiter to use as the separator for sections. With the exception of front-matter, which must be the very first thing in the string, the opening delimiter of all other sections must be followed by a string to be used as the key
for the section.
Example
1var input = '~~~\ntitle: bar\n~~~\n\nfoo\n~~~one\ntitle: One\n~~~\nThis is one'; 2console.log(sections(input, {section_delimiter: '~~~'}));
Results in:
1{ 2 content: '', 3 sections: [ 4 { 5 key: '', 6 data: 'title: bar', 7 content: '\nfoo' 8 }, 9 { 10 key: 'one', 11 data: 'title: One', 12 content: 'This is one' 13 } 14 ] 15}
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Please read the contributing guide for advice on opening issues, pull requests, and coding standards.
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
1$ npm install && npm test
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
1$ npm install -g verbose/verb#dev verb-generate-readme && verb
You might also be interested in these projects:
Jon Schlinkert
Copyright © 2017, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.6.0, on October 23, 2017.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/14 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Score
Last Scanned on 2025-05-05
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More