是否有可用的javascript插件可以为示例代码着色,使其看起来像在文本编辑器中一样?以php.net prinf页面为例,我想将其转换为:

<code>
    <?php<br>
        $num = 5;<br>
        $location = 'tree';<br>
        $format = 'There are %d monkeys in the %s';<br>
        printf($format, $num, $location);<br>
    ?>
</code>


对此

<code>
<span style="color: #000000">
    <span style="color: #0000BB">&lt;?php<br>$num&nbsp;</span>
    <span style="color: #007700">=&nbsp;</span>
    <span style="color: #0000BB">5</span>
    <span style="color: #007700">;<br></span>
    <span style="color: #0000BB">$location&nbsp;</span>
    <span style="color: #007700">=&nbsp;</span>
    <span style="color: #DD0000">'tree'</span>
    <span style="color: #007700">;<br><br></span>
    <span style="color: #0000BB">$format&nbsp;</span>
    <span style="color: #007700">=&nbsp;</span>
    <span style="color: #DD0000">'There&nbsp;are&nbsp;%d&nbsp;monkeys&nbsp;in&nbsp;the&nbsp;%s'</span>
    <span style="color: #007700">;<br></span>
    <span style="color: #0000BB">printf</span>
    <span style="color: #007700">(</span>
    <span style="color: #0000BB">$format</span>
    <span style="color: #007700">,&nbsp;</span>
    <span style="color: #0000BB">$num</span>
    <span style="color: #007700">,&nbsp;</span>
    <span style="color: #0000BB">$location</span>
    <span style="color: #007700">);<br></span>
    <span style="color: #0000BB">?&gt;</span>
</span>

最佳答案

google-code-prettify

10-07 17:05