Skip to content

Commit

Permalink
chore: build
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Oct 10, 2023
1 parent 340569f commit e09063c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ exports.VueReplMdPlugin = void 0;
const markdown_it_container_1 = __importDefault(require("markdown-it-container"));
function VueReplMdPlugin(md) {
const defaultRender = md.renderer.rules.fence;
const pattern = /^playground\s*(CodeMirror|Monaco)?\s*$/i;
md.use(markdown_it_container_1.default, 'playground', {
validate: function (params) {
return params.trim().match(/^playground\s*(.*)$/);
return params.trim().match(pattern);
},
render: function (tokens, idx) {
if (tokens[idx].nesting === 1) {
const vueToken = tokens.find(e => e.info === 'vue');
return `<VuePlayground>${encodeURIComponent(vueToken.content)}\n`;
const editor = tokens[idx].info.toLowerCase().indexOf('monaco') > -1 ? 'Monaco' : 'CodeMirror';
const vueToken = tokens.slice(idx).find(e => e.info === 'vue');
return `<VuePlayground editor="${editor}">${encodeURIComponent(vueToken.content)}\n`;
}
else {
// closing tag
Expand Down

0 comments on commit e09063c

Please sign in to comment.