meteorlxy / vue-showdown

:page_with_curl: Use showdown as a vue component
https://vue-showdown.js.org
MIT License
129 stars 23 forks source link

style of vue-showdown not show with vue template #13

Closed Navyroot closed 4 years ago

Navyroot commented 4 years ago

index.js

import Vue from 'vue';
import App from './App.vue';

Vue.config.productionTip = false;
import VueShowdown from 'vue-showdown'

// the second parameter of Vue.use() is optional
Vue.use(VueShowdown, {
  // set default flavor of showdown
  flavor: 'github',
  // set default options of showdown (will override the flavor options)
  options: {
    emoji: false,
  },
})

new Vue({
  render: h => h(App),
}).$mount('#app');

Vue template code :

<template>
  <div>
    <vue-showdown :markdown="fileContent"></vue-showdown> 
  </div>
</template>
<script>
import fileMd from 'raw-loader!../README.md'
export default {
  name: 'app',
  data() {
    return {
      fileContent: '## __Hello__',
    }
  },
  mounted() {
    this.fileContent = fileMd
  },
}
</script>

Markdown script :

Screen Shot 2019-12-18 at 8 03 03 AM

Result of my test page:

Screen Shot 2019-12-18 at 8 02 16 AM

Result demo page :

Screen Shot 2019-12-18 at 7 59 56 AM

meteorlxy commented 4 years ago

The markdown style does not come with vue-showdown nor showdown. You need to import it yourself.

The style of demo page comes from vuepress.

Try github-markdown-css, and add .markdown-body on your vue-showdown component.

Navyroot commented 4 years ago

Thx 🙏 , it's work .

Navyroot commented 4 years ago

How about Syntax highlighting ? Like this :

var foo = function(bar) {
  return bar++
}

console.log(foo(5))
package main

import "fmt"

func main() {
    fmt.Println("Hello, world!")
}
<ul>
  <li v-for="todo in todos" :key="todo.id">
    {{ todo.text }}
  </li>
</ul>
meteorlxy commented 4 years ago

It's out of scope of this vue component.

You can try something like highlight.js

Navyroot commented 4 years ago

Yes,thank I will try 😃

aycakahya commented 4 years ago

I have the same problem, how did you find a solution?