大家好,我使用SyntaxHighlighter作为博客代码高亮的插件,使用<pre class="brush: cpp"> source code </pre> 的形式,SyntaxHighlighter官网提示使用<pre>标签,必须把小写转换为< ,后来我自己又发现必须把 && 转换为 && ,现在又提示错误,我实在找不出原因,求助.代码如下:
<pre class="brush: cpp">
void BasicsCaller()
{
struct node* head;
int len;
head = BuildOneTwoThree(); // Start with {1, 2, 3}
Push(&head, 13); // Push 13 on the front, yielding {13, 1, 2, 3}
Push(&(head->next), 42); //push 42 into the second position yielding {13, 42, 1, 2, 3}
len = Length(head); // Computes that the length is 5.
}
</pre>
错误提示如下:
REXML could not parse this XML/HTML:
<pre class="brush: cpp">
void BasicsCaller()
{
struct node* head;
int len;
head = BuildOneTwoThree(); // Start with {1, 2, 3}
Push(&head, 13); // Push 13 on the front, yielding {13, 1, 2, 3}
Push(&(head->next), 42); //push 42 into the second position yielding {13, 42, 1, 2, 3}
len = Length(head); // Computes that the length is 5.
}
</pre>
<pre class="brush: cpp">
void BasicsCaller()
{
struct node* head;
int len;
head = BuildOneTwoThree(); // Start with {1, 2, 3}
Push(&head, 13); // Push 13 on the front, yielding {13, 1, 2, 3}
Push(&(head->next), 42); //push 42 into the second position yielding {13, 42, 1, 2, 3}
len = Length(head); // Computes that the length is 5.
}
</pre>
错误提示如下:
REXML could not parse this XML/HTML:
<pre class="brush: cpp">
void BasicsCaller()
{
struct node* head;
int len;
head = BuildOneTwoThree(); // Start with {1, 2, 3}
Push(&head, 13); // Push 13 on the front, yielding {13, 1, 2, 3}
Push(&(head->next), 42); //push 42 into the second position yielding {13, 42, 1, 2, 3}
len = Length(head); // Computes that the length is 5.
}
</pre>
void BasicsCaller()
{
struct node* head;
int len;
head = BuildOneTwoThree(); // Start with {1, 2, 3}
Push(&head, 13); // Push 13 on the front, yielding {13, 1, 2, 3}
Push(&(head->next), 42); //push 42 into the second position yielding {13, 42, 1, 2, 3}
len = Length(head); // Computes that the length is 5.
}
cpp;
echo '<pre "class="brush: cpp">'. htmlspecialchars($code) .'</pre>';另外如果要使用cpp的语法高亮,需要预先加载 scripts/shBrushCpp.js 脚本文件