Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,42 @@ export default {
</script>

```

#### Overriding temporarily markdown-it options

To use specific options "on the fly", you can proceed by altering temporarily, the `$md.options` flags.

`hello.vue`:
```html
<template>
<div v-html="rendered" />
</template>

<script>
export default {
props: {
markdown: { type: String, required: true },
options: { type: Object, default: null },
},
computed: {
rendered() {
const md = this.$md;
let backupOptions;
if (this.options) {
// Backup initial preset
backupOptions = Object.assign({}, md.options);
// Overrides options with props ones
Object.assign(md.options, this.options);
}
// Render
const rendered = md.render(this.markdown);
if (this.options) {
// Restore backuped options
md.options = backupOptions;
}
return rendered;
},
},
}
</script>
```