【发布时间】:2014-02-08 01:18:36
【问题描述】:
编辑:为了清晰和实际使用而进行的编辑。实际使用甚至可能使这种情况变得更容易?
我正在构建一个样式指南,我想为将要使用该指南的人包含常见样式/模式的源代码。我的计划是将所有繁重的 HTML 代码模块抽象到外部文件中,并使用 jQuery 将它们拉入,然后使用 SyntaxHighlighter 突出显示屏幕上显示的内容。下面的 HTML 显示了我的意图和我想做的事情。
我暂时删除了所有 JavaScript,因为它不会为手头的问题增加任何价值。我会更新我想出的任何东西。
<div class="sg-section">
<div class="sg-section-body">
<div data-load="markup/pagination.html"></div>
</div>
<div class="sg-section-code">
<small>Source Code</small>
<pre class="brush: js">
<!-- This is where I want to print out the contents -->
<!-- of the 'sg-section body' above and show it's source -->
</pre>
</div>
</div>
我可以使用简单的 $('[data-load]'.each(); 语句加载数据,但我很难将结果打印到 sg-section-code 并突出显示。
结论:切换到Prism。工作精美。
【问题讨论】:
标签: javascript jquery syntaxhighlighter