将 class 添加到 redactor 中的 pre 和 code 元素?

Adding class to pre and code element in redactor?

几天来我一直在尝试弄清楚如何将 class 添加到 Redactor 中的格式选项元素。

默认情况下,"Code" 的格式选项将内容包装在 <pre></pre><code></code> html 元素中。但是我需要让编校者改用 <pre class="prettyprint linenums"></pre><code class="prettyprint linenums"></code>

有谁知道一个简单的方法来做到这一点?几天来我一直在通过电子邮件来回发送 Redactor 支持,并尝试了 link 他们提供给我的文档 (http://imperavi.com/redactor/docs/settings/formatting/#setting-formattingAdd),但它只是破坏了整个事情...

PS: 我相当 javascript 弱智,我无法掌握或理解它是如何工作的,并且在做任何相关的事情时都遇到困难到 js.

如何将 class 添加到 redactor 的 "Code" 格式选项,将内容包装在前 HTML 元素中?

已将 $( "pre" ).addClass( "prettyprint linenums" ); 添加到另一个在加载时运行的函数。

才注意到你自己回答了,你有没有让它工作过?
我很快就实现了它,看看会发生什么,你的另一个 post 我想你可能知道结果如何。
这是我得到的...
http://plnkr.co/edit/B5F3bn6I0ofqTaY7NkZg?p=preview

   $(function() {
    $('#redactor').redactor({
      focus: true,
      buttonSource: true,
      //        formatting: ['p', 'blockquote', 'h1', 'h2'],
      formattingAdd: [{
        tag: 'pre',
        title: 'Pretty Print',
        class: 'prettyprint linenums'
      }],
        syncCallback: function()
{
    prettyPrint();
}
    });
  }); 

...这会添加一个格式选项,将选定的内容包装在 class 的 pre 中,然后 运行 prettyPrint 在转换它之后......然后问题就开始了;)
哦,好吧,如果你想通了,我很想知道,至少这说明了如何添加格式选项。