今天把的我的blog换了个新的空间,测试的时候发现dp.SyntaxHighlighter 代码高亮不好使,调试了一下才发现原来里面有个bug刚好被我碰上,今天真他妈该买彩票去。
虽然我常写php,但是我这次却尝试高亮c++的代码,出现了404错误,原因:
highlighter/highlighter.html 中有段代码:
- var TypeMapper = {
- "php" : PREFIX + "Php" + POSTFIX ,
- "javascript" : PREFIX + "JScript" + POSTFIX ,
- "java" : PREFIX + "Java" + POSTFIX ,
- "xml" : PREFIX + "Xml" + POSTFIX ,
- "html" : PREFIX + "Xml" + POSTFIX ,
- "c++" : PREFIX + "Cpp" + POSTFIX ,
- "cpp" : PREFIX + "Cpp" + POSTFIX ,
- "c#" : PREFIX + "CSharp" + POSTFIX ,
- "css" : PREFIX + "Css" + POSTFIX ,
- "delphi" : PREFIX + "Delphi" + POSTFIX ,
- "python" : PREFIX + "Python" + POSTFIX ,
- "ruby" : PREFIX + "Ruby" + POSTFIX ,
- "sql" : PREFIX + "Sql" + POSTFIX ,
- "vb" : PREFIX + "Vb" + POSTFIX
- };
|
var TypeMapper = { "php" : PREFIX + "Php" + POSTFIX , "javascript" : PREFIX + "JScript" + POSTFIX , "java" : PREFIX + "Java" + POSTFIX , "xml" : PREFIX + "Xml" + POSTFIX , "html" : PREFIX + "Xml" + POSTFIX , "c++" : PREFIX + "Cpp" + POSTFIX , "cpp" : PREFIX + "Cpp" + POSTFIX , "c#" : PREFIX + "CSharp" + POSTFIX , "css" : PREFIX + "Css" + POSTFIX , "delphi" : PREFIX + "Delphi" + POSTFIX , "python" : PREFIX + "Python" + POSTFIX , "ruby" : PREFIX + "Ruby" + POSTFIX , "sql" : PREFIX + "Sql" + POSTFIX , "vb" : PREFIX + "Vb" + POSTFIX }; |
原本里面只有 "c++"的map,没有"cpp”map,但是同页面中代码:
- <SELECT name="codeType" id="codeType" onChange="setCodeType(this.value);">
- <OPTION value="" FCKLANG="DlgSyntaxHighLighterSelectLang">语言</OPTION>
- <OPTION value="cpp">C++</OPTION>
- <OPTION value="c#">C#</OPTION>
- <OPTION value="css">CSS</OPTION>
- <OPTION value="delphi">Delphi</OPTION>
- <OPTION value="java">Java</OPTION>
- <OPTION value="javascript">JavaScript</OPTION>
- <OPTION value="php">PHP</OPTION>
- <OPTION value="python">Python</OPTION>
- <OPTION value="ruby">Ruby</OPTION>
- <OPTION value="sql">SQL</OPTION>
- <OPTION value="xml">XML</OPTION>
- <OPTION value="vb">VB</OPTION>
- </SELECT>
|
<SELECT name="codeType" id="codeType" onChange="setCodeType(this.value);"> <OPTION value="" FCKLANG="DlgSyntaxHighLighterSelectLang">语言</OPTION> <OPTION value="cpp">C++</OPTION> <OPTION value="c#">C#</OPTION> <OPTION value="css">CSS</OPTION> <OPTION value="delphi">Delphi</OPTION> <OPTION value="java">Java</OPTION> <OPTION value="javascript">JavaScript</OPTION> <OPTION value="php">PHP</OPTION> <OPTION value="python">Python</OPTION> <OPTION value="ruby">Ruby</OPTION> <OPTION value="sql">SQL</OPTION> <OPTION value="xml">XML</OPTION> <OPTION value="vb">VB</OPTION> </SELECT> |
"c++" 对应的value为“cpp” 于是就找不到东西了
解决办法:
在数组TypeMapper 中添加cpp的map就行了。