diff --git a/packages/@vuepress/markdown/lib/contentSlotsContainers.js b/packages/@vuepress/markdown/lib/contentSlotsContainers.js new file mode 100644 index 0000000000..c70101f122 --- /dev/null +++ b/packages/@vuepress/markdown/lib/contentSlotsContainers.js @@ -0,0 +1,12 @@ +const container = require('markdown-it-container') + +const SLOT_KEY = 'slot' + +module.exports = md => { + md + .use(container, SLOT_KEY, { + render: (tokens, idx) => tokens[idx].nesting === 1 + ? `' + }) +} diff --git a/packages/@vuepress/markdown/lib/index.js b/packages/@vuepress/markdown/lib/index.js index 2b44e8c25d..e11c324a13 100644 --- a/packages/@vuepress/markdown/lib/index.js +++ b/packages/@vuepress/markdown/lib/index.js @@ -13,6 +13,7 @@ const componentPlugin = require('./component') const hoistScriptStylePlugin = require('./hoist') const convertRouterLinkPlugin = require('./link') const containersPlugin = require('./containers') +const contentSlotsContainersPlugin = require('./contentSlotsContainers') const snippetPlugin = require('./snippet') const emojiPlugin = require('markdown-it-emoji') const anchorPlugin = require('markdown-it-anchor') @@ -75,6 +76,10 @@ module.exports = ({ .use(containersPlugin) .end() + .plugin('content-slots-containers') + .use(contentSlotsContainersPlugin) + .end() + .plugin('emoji') .use(emojiPlugin) .end()