nkvs-md-creator
v1.0.0
Published
Markdown creator.
Readme
nkvs-md-creator
test
table
import { createTable } from 'nkvs-md-creator'
const data = {
element: 'table',
head: ['name', 'type', 'description'],
align: ['left', 'center', 'right'],
body: [
['name1', 'type1', 'description1'],
['name2', 'type2', 'description2']
]
}
const result = createTable(data)
console.log(result)| name | type | description |
| :--- | --- | ---: |
| name1 | type1 | description1 |
| name2 | type2 | description2 |h
import { createH } from 'nkvs-md-creator'
const data = {
element: 'h',
depth: 6,
text: 'function',
id: 'custom-id'
}
const result = createH(data)
console.log(result)###### functionhr
import { createHr } from 'nkvs-md-creator'
const data = {
element: 'hr'
}
const result = createHr(data)
console.log(result)---pre
import { createPre } from 'nkvs-md-creator'
const data = {
element: 'pre',
language: 'JavaScript',
text: 'function add(a, b) {\n return a + b\n}'
}
const result = createPre(data)
console.log(result)```JavaScript
function add(a, b) {
return a + b
}
```list
import { createList } from 'nkvs-md-creator'
const data = {
element: 'ul',
children: [
{
text: '123',
child: {
element: 'ol',
children: [
{
text: '123',
child: {
element: 'ul',
children: [
{
text: '123'
},
{
text: '123'
}
]
}
},
{
text: '123'
}
]
}
},
{
text: '123',
child: {
element: 'checkbox-list',
children: [
{
text: '123',
checked: true
},
{
text: '123'
}
]
}
},
{
text: '123',
child: {
element: 'radio-list',
children: [
{
text: '123',
checked: true
},
{
text: '123'
}
]
}
},
{
text: '123',
child: {
element: 'dl',
children: [
{
element: 'dt',
text: '123'
},
{
element: 'dd',
text: '123'
}
]
}
}
]
}
const result = createList(data)
console.log(result)- 123
1. 123
- 123
- 123
2. 123
- 123
- [x] 123
- [ ] 123
- 123
- (x) 123
- ( ) 123
- 123
123
: 123text
import { createText } from 'nkvs-md-creator'
const data = {
element: 'template',
children: [
{
element: 'a',
text: 'image',
href: 'https://www.baidu.com',
child: {
element: 'template',
children: [
{
element: 'img',
src: 'http',
alt: 'image',
title: '123'
}
]
}
},
{
element: 'em',
text: 'image',
child: {
element: 'template',
children: [
{
element: 'strong',
text: '123'
}
]
}
},
{
element: 'code',
text: 'function add(a, b) { return a + b }'
},
{
element: 'sup',
text: 'test'
},
{
element: 'sub',
text: 'test'
},
{
element: 'mark',
text: 'test'
},
{
element: 'del',
text: 'test'
}
]
}
const result = createText(data)
console.log(result)[image](https://www.baidu.com)*image**123***`function add(a, b) { return a + b }`^test^~test~==test==~~test~~blockquote
import { createBlockquote } from 'nkvs-md-creator'
const data = {
element: 'blockquote',
type: 'warning',
title: 'Warning',
children: [
{
text: '- Revenue was off the chart.\n- Profits were higher than ever.\n- 123'
},
{
type: 'bulb',
title: 'Tip',
children: [
{
text: 'No!!!'
}
]
},
{
text: '- Revenue was off the chart.\n- Profits were higher than ever.\n- 123'
},
{
text: '*Everything* is going according to **plan**.'
}
]
}
const result = createBlockquote(data)
console.log(result)> :warning: **Warning**
>
> - Revenue was off the chart.
> - Profits were higher than ever.
> - 123
>
>> :bulb: **Tip**
>>
>> No!!!
>
> - Revenue was off the chart.
> - Profits were higher than ever.
> - 123
>
> *Everything* is going according to **plan**.component
import { createComponent } from 'nkvs-md-creator'
const data = {
element: 'custom',
component: 'componentName',
attrs: 'class="p-4"',
children: [
{
text: '1'
},
{
component: 'componentName',
attrs: 'class="p-4"',
children: [
{
text: '1.1'
},
{
component: 'componentName',
attrs: 'class="p-4"',
}
]
},
{
text: '1'
}
]
}
const result = createComponent(data)
console.log(result)::componentName class="p-4"
1
::componentName class="p-4"
1.1
::componentName class="p-4"
::
::
1
::