slate-serializers
View project on npmView project on GitHub

Convert Slate JSON to Markdown

Config:  Default.
Change configuration

Default

slateToMarkdown

Demo

Try changing the contents of this editor. The rest of the page updates as you make changes to demonstrate:

  • the Slate JSON value; and
  • Markdown generated by slateToMarkdown.

Marks such as bold, italic and inline code use Markdown syntax. Underline has none, so it is written as an HTML tag.

Characters like * and _ in text are escaped so they stay literal.
  1. Ordered lists
  2. keep their numbering.
## slateToMarkdown

### Demo

Try changing the contents of this editor. The rest of the page updates as you make changes to demonstrate:

- the Slate JSON value; and
- Markdown generated by `slateToMarkdown`.

Marks such as **bold**, *italic* and `inline code` use Markdown syntax. <u>Underline</u> has none, so it is written as an HTML tag.

> Characters like \* and \_ in text are escaped so they stay literal.

1. Ordered lists
2. keep their numbering.
{
	type: 'h2',
	children: [
		{
			text: 'slateToMarkdown'
		}
	]
}
{
	type: 'h3',
	children: [
		{
			text: 'Demo'
		}
	]
}
{
	type: 'p',
	children: [
		{
			text: 'Try changing the contents of this editor. The rest of the page updates as you make changes to demonstrate:'
		}
	]
}
{
	type: 'ul',
	children: [
		{
			type: 'li',
			children: [
				{
					text: 'the Slate JSON value; and'
				}
			]
		},
		{
			type: 'li',
			children: [
				{
					text: 'Markdown generated by '
				},
				{
					text: 'slateToMarkdown',
					code: true
				},
				{
					text: '.'
				}
			]
		}
	]
}
{
	type: 'p',
	children: [
		{
			text: 'Marks such as '
		},
		{
			text: 'bold',
			bold: true
		},
		{
			text: ', '
		},
		{
			text: 'italic',
			italic: true
		},
		{
			text: ' and '
		},
		{
			text: 'inline code',
			code: true
		},
		{
			text: ' use Markdown syntax. '
		},
		{
			text: 'Underline',
			underline: true
		},
		{
			text: ' has none, so it is written as an HTML tag.'
		}
	]
}
{
	type: 'blockquote',
	children: [
		{
			text: 'Characters like * and _ in text are escaped so they stay literal.'
		}
	]
}
{
	type: 'ol',
	children: [
		{
			type: 'li',
			children: [
				{
					text: 'Ordered lists'
				}
			]
		},
		{
			type: 'li',
			children: [
				{
					text: 'keep their numbering.'
				}
			]
		}
	]
}