highlightjs / vue-plugin

Highlight.js Vue Plugin
BSD 3-Clause "New" or "Revised" License
207 stars 28 forks source link

Is it working right now? #21

Closed arneesh closed 3 years ago

arneesh commented 3 years ago

I added it to a Vue 3 project and the output I am getting is this(Attached a screenshot below). Even with specifically setting the language to js.

Dependency Versions

Installation

import hljs from 'highlight.js/lib/core';
import javascript from 'highlight.js/lib/languages/javascript';
import hljsVuePlugin from "@highlightjs/vue-plugin";
hljs.registerLanguage('javascript', javascript);

 app.use(hljsVuePlugin)

Usage: Step 1

<template>
       <highlightjs
        language="js"
        code="function chipPaginate(page) {
    if (typeof sortOrderNew === 'undefined')
        var sortOrder = 3;

    if (typeof sortOrderNew !== 'undefined')
        var sortOrder = sortOrderNew;

    console.log(sortOrder);
}
"
    />
</template>

Usage: Step 2

<script>
  components: {
        "highlightjs": hljsVuePlugin.component
  },
</script>

Output

Screenshot 2021-10-09 at 1 13 31 AM
Trinovantes commented 3 years ago

language="js" should be language="javascript"

joshgoebel commented 3 years ago

Why? Pretty sure the component supports aliass just fine.

arneesh commented 3 years ago

Thanks for the quick response guys. @Trinovantes I tried that as well. Wasn't working either...

Trinovantes commented 3 years ago

Can you provide a repo?

edit: I suspect you're not importing a theme CSS e.g. import 'highlight.js/styles/stackoverflow-light.css'

arneesh commented 3 years ago

Ah, yes that was the issue. Thanks for the help I appreciate it.