https://github.com/chmac/util-md-to-arrays
Take a markdown file and split it into an array of segments, with lists further split into arrays of items
https://github.com/chmac/util-md-to-arrays
index markdown search
Last synced: about 1 month ago
JSON representation
Take a markdown file and split it into an array of segments, with lists further split into arrays of items
- Host: GitHub
- URL: https://github.com/chmac/util-md-to-arrays
- Owner: chmac
- License: agpl-3.0
- Created: 2022-02-15T08:26:53.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-03-01T13:58:34.000Z (over 3 years ago)
- Last Synced: 2025-02-14T04:39:48.930Z (over 1 year ago)
- Topics: index, markdown, search
- Language: TypeScript
- Homepage:
- Size: 168 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# util-md-to-arrays
Given a markdown segment like:
```
A paragraph
- Item 1
- Item 1.1
- Item 1.2
- Item 2
```
This utility will return an array like:
```javascript
[
`A paragraph`,
[
`- Item 1\n - Item 1.1\n - Item 1.2`,
`- Item 2`,
]
]
```
Or put differently, the markdown input will be split into an array of segments,
and any lists will be further split into an array of items. Note that nested
lists are included as part of the parent list.
Also note that frontmatter is not supported and any input string which begins
with `---\n` will throw.