Javascript 使用CKEditor代码片段突出显示.js

Javascript 使用CKEditor代码片段突出显示.js,javascript,jquery,ckeditor,highlight.js,Javascript,Jquery,Ckeditor,Highlight.js,我试图将highlight.js与CKEditoraddoncodesippet一起使用 我有CKEditor工作,包括CodeSnippet插件,但我的代码没有被检测到,也没有被颜色编码或缩进,或者像我预期的那样 正在阅读highlight.js它说 这将查找并突出显示预编码标签内的代码;它尝试 自动检测语言。如果自动检测不起作用 如果要为您工作,可以在“类”属性中指定语言: 这是HTML文件中的JavaScript,用于调用highlight.js: <script src="{% s

我试图将
highlight.js
CKEditor
addon
codesippet
一起使用

我有
CKEditor
工作,包括
CodeSnippet
插件,但我的代码没有被检测到,也没有被颜色编码或缩进,或者像我预期的那样

正在阅读highlight.js它说

这将查找并突出显示预编码标签内的代码;它尝试 自动检测语言。如果自动检测不起作用 如果要为您工作,可以在“类”属性中指定语言:

这是HTML文件中的JavaScript,用于调用
highlight.js

<script src="{% static 'js/ckeditor/plugins/codesnippet/lib/highlight/highlight.pack.js' %}"></script>
<script>hljs.initHighlightingOnLoad();</script>
这就解决了它:

CKEDITOR_CONFIGS = {
    'default': {
        'skin': 'bootstrapck',
        'toolbar': 'Custom',
        'toolbar_Custom': [
            {'name': 'basicstyles', 'items': ['Bold', 'Italic', 'Underline', '-', 'RemoveFormat']},
            {'name': 'paragraph', 'items': ['NumberedList', 'BulletedList']},
            {'name': 'indent', 'items': ['Indent', 'Outdent']},
            {'name': 'codeSnippet', 'items': ['CodeSnippet',]}
        ],
        'codeSnippet_theme': 'school_book',
        'tabSpaces' : 4,
        'extraPlugins': ','.join(
            [
            'codesnippet',
            'widget',
            'dialog',
            ]),
    }
}

您的配置看起来不错。您是否检查了highlight.js是否在不使用CKEditor的情况下使用最少的代码@HBat我最终解决了它,如答案所示(我刚刚添加)
CKEDITOR_CONFIGS = {
    'default': {
        'skin': 'bootstrapck',
        'toolbar': 'Custom',
        'toolbar_Custom': [
            {'name': 'basicstyles', 'items': ['Bold', 'Italic', 'Underline', '-', 'RemoveFormat']},
            {'name': 'paragraph', 'items': ['NumberedList', 'BulletedList']},
            {'name': 'indent', 'items': ['Indent', 'Outdent']},
            {'name': 'codeSnippet', 'items': ['CodeSnippet',]}
        ],
        'codeSnippet_theme': 'school_book',
        'tabSpaces' : 4,
        'extraPlugins': ','.join(
            [
            'codesnippet',
            'widget',
            'dialog',
            ]),
    }
}