0

Using the below code, I am getting the raw html instead and not formatted syntax. what am I missing?

<script setup>
import hljs from 'highlight.js/lib/core';
import sql from 'highlight.js/lib/languages/sql.js';

hljs.registerLanguage('sql', sql);

const highlightedCode = hljs.highlight(
    'select * from TableName',
    { language: 'sql' }
).value


</script>

<template>
    <pre>
    <code>
        {{ highlightedCode }}
    </code>
  </pre>
</template>

1 Answer 1

0

I think you have a problem with the style. You can try again by importing the style file.

For example:

import 'highlight.js/styles/stackoverflow-light.css'

or

import 'highlight.js/styles/github.css';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.