-
Notifications
You must be signed in to change notification settings - Fork 62
[Question] How can I get parsed markdown from vuepress-plugin-container? #20
Comments
What do you mean by "get parsed markdown"? Do you want to get the literal code, rather than HTML rendered? So why not wrap it in markdown code block? ::: demo
```html
<button class="demo">demo</button>
```
::: |
Uh I guess I got your point. You want to get both "rendered HTML" and "literal code" in the mean time. An interesting feature. I have no good idea for now. Maybe there are two different ways for this:
🤔 |
Currently we repeat the code for demo. You can check how vuepress official docs does: https://github.com/vuejs/vuepress/blame/master/packages/docs/docs/guide/markdown.md#L90-L100 |
Yeah! Thank you for your reply. |
In fact I think it is out of scope of plugin-container. We can make it another plugin, or intergrate it into vuepress' default theme |
I find bootstrap and element both use similar features. Bootstrap use hugo-plugin. And element write some configs about markdown-it. |
I see. ElementUI is using "markdown-it + vue" way as I mentioned above. See https://github.com/ElemeFE/element/blob/0706805226cc8ad90011a568c1a14bf0701abd37/examples/components/demo-block.vue |
Yeah, I also used this method to implement the container of demo. |
I did the same but I have issues with the script part of demo code. For example if I got two components going through the demo, they seem to apply as a parent and overwrite each other. So the last demo I made is the only Meaning I can't have multiple demo examples on the same page. Not sure why, can't see the difference between method and Elements method. Anyone else have that issue? |
This part handles displaying the code to a PrismJS component I created in Vue. Works well. Now to handle the rendering of the demo-component tag.
The previous method I used to render the components failed to handle script tags well. Like I mentioned previously, they kept replacing one an other if there was multiple ones. Hoping this new approach based on ElementUI will solve it, will comment again if I find a good solution for that part. |
@henrikdahl Looks good! |
@YunYouJun Thanks! Also thanks for sharing. vuepress-plugin-demo-code has the same bug I mentioned above. Was using that one as a reference to begin with. The other one doesn't use a Vue component as a base which is a requirement for me. I'm thinking it might share the same bug as well. Haven't tried that one. I got it to render both the code and the demo part, however the script tag throws an error and hence the components don't work properly. Any suggestions? How did you get script tags working properly? With two way binding (v-model) and such? |
In fact, I didn't find this problem until you mentioned it. I think it may be caused by script-style-hoisting. I tried it and no better method found. Since they both need
<template>
<input :disabled="disabled" />
</template>
<script>
export default {
data() {
return {
disabled: true
};
}
};
</script>
<template>
<input :disabled="disabled" />
</template>
<script>
export default {
data() {
return {
disabled: false
};
}
};
</script> Docs markdown <test-demo1/>
<<< @/docs/.vuepress/components/test-demo1.vue
<test-demo2/>
<<< @/docs/.vuepress/components/test-demo2.vue |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Environment
What's your question?
How can I get parsed markdown from vuepress-plugin-container?
I cannot find it in docmention.
I want to implement a demo type container.
I just need input:
Then I can get:
and display its code:
But I cannot get the code in markdown.
By the way, I think this is a useful function. It can be added as a default feature like
:::tip
.The text was updated successfully, but these errors were encountered: