How to output CKEditor code snippets with matching styles

怎甘沉沦 提交于 2020-06-28 09:01:18

问题


I have a question to the CKEditor... First I have to say, that I searched now for over 3 hours and I don't know, if I'm so bad or why I found nothing... I'm searching for a way, how to output CKEditor-Text with the right Styles AND I added a Syntax-Highlighter-Plugin (Code Snippet) for which I also want the right styles...

Can someone help me, how to format this with right styles?

Input:

Output:

Code:

<h1>Hello world!</h1>
<p>I&#39;m an instance of <a href="http://ckeditor.com">CKEditor</a>.</p>
<pre>
   <code class="language-javascript">
      var i = "test";
      alert(i);
   </code>
</pre>

回答1:


It's a bit funny that you said you've been looking for an answer for 3 hours as it is explained right in the official documentation for this feature. Sometimes it makes sense to just check the docs, probably :)

Target Page

To see the highlighter styles on the target page where CKEditor content is displayed, you will need to load the highlight.js script and theme's stylesheet on this page. You can either reuse a copy of highlight.js placed in the ckeditor/plugins/codesnippet/lib/highlight directory or download your own copy from the highlight.js download page. (...)

Read more details and grab some code here: http://docs.ckeditor.com/#!/guide/dev_codesnippet-section-target-page



来源:https://stackoverflow.com/questions/34981774/how-to-output-ckeditor-code-snippets-with-matching-styles

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!