vue3-markdown-it
vue3-markdown-it copied to clipboard
When I write MarkDown in <vue3-markdown-it></vue3-markdown-it> it is not working.
Describe the bug
When I write MarkDown in :source="source". It is displaying some of the markdown, but some of them are not working.
To Reproduce Steps to reproduce the behavior:
- Create a Quasar framework(Vue) project.
- Include framework settings in boot file.
- Create a test page with some example.
- See error
Expected behavior
Using Markdown between
Screenshots No, screenshot!
Additional context No additional context.
Hi @OtabekSadiridinov!
Can you elaborate more on which markdown functionality isn't working?
The main issue being reported here is that you can't pass data along with slots; it has to be passed in via source which can be somewhat unwieldy in some cases
Yes, it does not work, I solve the problem by making one component and wrap the data into that markdown component:
CustomMarkdown.vue
<template>
<div>
<span ref="markdownCode">
<slot></slot>
</span>
<Markdown :source="markdownCode" />
</div>
</template>
<script lang="js">
import Markdown from 'vue3-markdown-it';
export default {
name: "CustomMarkdown",
components: {
Markdown,
},
data () {
return {
markdownCode: ""
}
},
mounted() {
let elem = this.$refs.markdownCode
this.markdownCode = elem.textContent;
elem.remove();
}
}
</script>
And I can use that component anywhere like.
<template>
<vue-markdown># this is the default slot</vue-markdown>
</template>
<script lang="js">
import CustomMarkdown from '@/components/CustomMarkdown';
export default {
name: "Post",
components: {
'vue-markdown': CustomMarkdown,
},
}
That's all.
But it will be good if that component support that functionality out of the box.