Skip to content
This repository has been archived by the owner on Apr 15, 2018. It is now read-only.

janm6k/testtask-markdown-sections

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Parse two levels of headers from markdown file.

It transforms this markdown:

# Main header

First paragraph

## Subheader

Subheader text

# Second header

into

{
	sections: [
		{
			name: 'Main header',
			text: ['para', 'First paragraph'], // markdown-js JsonMl
			subsections: [
				{
					name: 'Subheader',
					text: ['para', 'Subheader text']
				}
			]
		},
		{
			name: 'Second header'
		}
	]
}

Content before first header is put into "preamble" section, with name set to null.

Run tests

To try it out run the tests:

> npm test

If you want to add more testcases to see what conditions I failed to consider, just add it to test/sections.coffee

About

Parse two levels of headers from markdown file

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published