CodeMirror.js是一个功能强大的 JavaScript 库,为 Web 应用提供了代码编辑器组件。它提供了多种功能,包括语法高亮、代码折叠、自动补全和可自定义的主题。
官网地址:https://codemirror.net//
GitHub仓库:https://github.com/codemirror/dev/
codemirror.js语法高亮示例
javascript语法高亮点击查看案例效果>>
<script>
function test(a,b){
var c;
if(a>b){
c="a > b"
}else{
c="a < b"
}
return 'return = ' +c
}
alert(test(1,2))
</script>
vbscript语法高亮点击查看案例效果>>
<%
function mytest()
if 1=1 then
response.write("aa")
end if
end function
%>
php语法高亮点击查看案例效果>>
<?PHP
function hello($who) {
$a=1;
$b=2;
$c='';
if($a>$b){
$c ='a > b';
}else{
$c ='b < a';
}
return "Hello $who! " . $c;
}
echo(hello("小明"));
?>
css语法高亮点击查看案例效果>>
<style>
body{
width:100%;
height:100px;
font-size:12rem;
color:"red"!important;
}
</style>