highlightjs / vue-plugin

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

Providing a language doesn't disable autodetect #41

Closed barrycohen closed 1 year ago

barrycohen commented 1 year ago

The following does not use shell highlighting:

<highlightjs language="shell" code="#include <iostream>"></highlightjs>

Instead, it autodetects cpp and uses that, even though "shell" was explicitly provided. It is possible to force autodetect off but I don't think that's supposed to be required:

<highlightjs :autodetect="false" language="shell" code="#include <iostream>"></highlightjs>

See this fiddle https://jsfiddle.net/5nvhra3p/ for a live example.

I think there's a logic error in vue.ts:

const autodetect = computed(() => props.autodetect || !language.value)

I think this should be:

const autodetect = computed(() => props.autodetect && !language.value)
joshgoebel commented 1 year ago

I think you may be right, could you test and make a PR perhaps?