question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to load codeSyntaxHighlight in Vue 2

See original GitHub issue

Summary

I am unable to load the codeSyntaxHighlight plugin in a Vue 2 project.

Here is a shortened version of the code for the Vue single file component:

<template>
    <div class="note-body">
        <Editor
            :options="options"
            previewStyle="tab"
            ref="bodyEditor"
            height="1000px"
            :initialValue="newBody"
            @change="onEditorChange"
        />
    </div>
</template>

<script>
import '@toast-ui/editor/dist/toastui-editor.css';
import 'prismjs/themes/prism.css';
import '@toast-ui/editor-plugin-code-syntax-highlight/dist/toastui-editor-plugin-code-syntax-highlight.css';

import {Editor} from '@toast-ui/vue-editor';
import codeSyntaxHighlight from '@toast-ui/editor-plugin-code-syntax-highlight';

export default {
    name: 'NoteBody',
    components: {
        Editor
    },
    data: function() {
        return {
            newBody: '# Example text',
            options: {
                hideModeSwitch: true,
                toolbarItems: [
                    ['quote'],
                    ['task'],
                    ['link'],
                    ['code', 'codeblock']
                ],
                plugins: [codeSyntaxHighlight]
            }
        };
    }
};
</script>

There also is some custom CSS for the component, but commenting it out doesn’t fix the issue.

Here are the relevant dependencies and versions in package.json:

"@toast-ui/editor-plugin-code-syntax-highlight": "^3.0.0",
"@toast-ui/vue-editor": "^3.1.5",
"prismjs": "^1.28.0",
"vue": "^2.6.14",

Version

3.1.5

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nik312123commented, May 18, 2022

Sounds good. Thank you very much for the help! I think this issue can be closed then.

1reaction
jwlee1108commented, May 18, 2022

@nik312123

Oh, I’m so sorry. There were lots of tasks to handle on me. I just made the environment by referring to your issue. But, there is no problem. Could you check this link?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Syntax highlighting is broken · Issue #660 · vuejs/vetur - GitHub
Problem. Syntax highlighting isn't working across the board. I had this extension installed through Sarah Drasner's Vue VS Code Extension Pack, ...
Read more >
why vs code syntax highlighting stop working - Stack Overflow
i use vue and vuex. i just realised that the syntax highlighting stops in the middle of the .js file. what could be...
Read more >
Using Syntax Highlighting in this forum - Get Help
Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this...
Read more >
Install Vue Syntax Highlighting via Package Control ... - Medium
Install Vue Syntax Highlighting package​​ Press Command-Shift-P (Mac OS X) or Ctrl-Shift-P (Windows) to open the Command Palette. Select Package Control: Install ......
Read more >
How to use highlight.js
To skip highlighting of a code block completely, use the nohighlight class: ... load the library and ALL languages hljs = require('highlight.js'); html ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found