1
4

1 回答 1

2

我想到了。当 jQuery 扫描并用等效的 Unicode 替换标记插入符号时,就会出现问题。

这是我的解决方案。我决定动态添加标记块,所以你会看到我在每个 live-example 块之后添加了一个 div,用来自 live 示例的代码作为文本而不是 HTML 填充它(这是诀窍让它工作),然后将其包装在<pre>标签中。

// Add a markup block after each live example container
$('.live-example').after("<div class='markup'></div>");

// Fill the markup block with the code from the live container
$('.live-example').each(function () {
    $(this).next($('.markup')).text($(this).html());
});

// Wrap the code in the markup block with a <pre> tag for prettyprinting
$('.markup').wrapInner('<pre class="prettyprint linenums" />');

在我的代码之前和之后,我仍然感到奇怪<br>,但我可以处理。

结果:

在此处输入图像描述

于 2013-05-26T06:02:35.603 回答