程序代码

程序代码的输入与高亮显示


这里采用 SHJS 对HTML中程序代码进行高亮显示, SHJS可以支持很多语言, 如 C, C++, PHP, Perl, LaTeX 等.

BisonJava properties filesPHP
CJavaScriptProlog
C++JavaScript with DOMPython
C#LaTeXRPM spec files
ChangeLogLDAP filesRuby
CSSLog filesS-Lang
Desktop filesLSM (Linux Software Map) filesScala
DiffM4Shell
FlexMakefileSQL
GLSLObjective CamlStandard ML
HaxeOracle SQLTcl
HTMLPascalXML
JavaPerlXorg configuration files

用法

将源代码放入<pre class="sh_xxx"></pre>块中即可, 这里 sh_xxx 视源代码而定, sh 是前缀, 代表 SHJS.

如源代码是C++, 则 class="sh_cpp"; 如果是 LaTeX, 则 class="sh_latex", 详见下面的例子.

显示效果
#include <iostream>

using namespace std;

int main(int argc, char ** argv) {
  cout << "Hello world" << endl;
  return 0;
}
LaTeX
显示效果
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\end{document}


The following table shows the correct class to use for each language:
Language HTML class
Bison sh_bison
C sh_c
C++ sh_cpp
C# sh_csharp
ChangeLog sh_changelog
CSS sh_css
Desktop files sh_desktop
Diff sh_diff
Flex sh_flex
GLSL sh_glsl
Haxe sh_haxe
HTML sh_html
Java sh_java
Java properties files sh_properties
JavaScript sh_javascript
JavaScript with DOM sh_javascript_dom
LaTeX sh_latex
LDAP files sh_ldap
Log files sh_log
LSM (Linux Software Map) files sh_lsm
M4 sh_m4
Makefile sh_makefile
Objective Caml sh_caml
Oracle SQL sh_oracle
Pascal sh_pascal
Perl sh_perl
PHP sh_php
Prolog sh_prolog
Python sh_python
RPM spec files sh_spec
Ruby sh_ruby
S-Lang sh_slang
Scala sh_scala
Shell sh_sh
SQL sh_sql
Standard ML sh_sml
Tcl sh_tcl
XML sh_xml
Xorg configuration files sh_xorg