A KduPress plugin that registers markdown containers.
npm install kdupress-plugin-container
# OR
yarn add kdupress-plugin-container
// config.js
module.exports = {
plugins: [
// you can use it multiple times
// so babel-style may be a better choice
['container', {
type: 'right',
defaultTitle: '',
}],
['container', {
type: 'theorem',
before: info => `<div class="theorem"><p class="title">${info}</p>`,
after: '</div>',
}],
]
}
// index.styl
.theorem
margin 1rem 0
padding .1rem 1.5rem
border-radius 0.4rem
background-color #f0f4f8
.title
font-weight bold
.custom-block
&.right
color transparentify($textColor, 0.4)
font-size 0.9rem
text-align right
- type:
string
- required:
true
The type for the container. For example, if type
is set to foo
, only the following syntax will be parsed as a container:
::: foo bar
write something here ~
:::
- type:
string | Record<string, string>
- default: the upper case of
type
The default title for the container. If no title is provided, defaultTitle
will be shown as the title of the container. If an object was specified, the default title will depend on current locale.
- type:
string | Function
- default:
undefined
String to be placed before the block. If specified as a function, an argument info
will be passed to it. (In the example above, info
will be bar
.) If specified, it will override defaultTitle
.
- type:
string | Function
- default:
undefined
String to be placed after the block. If specified as a function, an argument info
will be passed to it. (In the example above, info
will be bar
.) If specified, it will override defaultTitle
.
- type:
Function
- default:
undefined
A function to validate tail after opening marker, should return true
on success.
- type:
Function
- default:
undefined
The renderer function for opening/closing tokens. If specified, it will override before
, after
and defaultTitle
.
- type:
string
- default:
':'
The character to use as a delimiter.
Contribution Welcome!