JavaScript & jQuery
[JavaScript] Syntax Highlighting
Jane Kwon
2021. 2. 10. 14:05
반응형
* 프로그래밍 언어를 라인 지켜서 예쁘게 출력
<!DOCTYPE html>
<html lang="en">
<head>
<title>ACE in Action</title>
<style type="text/css" media="screen">
#editor {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
</style>
</head>
<body>
<div id="editor">
function foo(items) {
var x = "All this is syntax highlighted";
return x;
}
</div>
<script src="/ace-builds/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.session.setMode("ace/mode/javascript");
</script>
</body>
</html>
- editor.setTheme("ace/theme/monokai"); 필요에 따라 테마 변경 가능
- editor.session.setMode("ace/mode/javascript"); 필요에 따라 모드 변경 가능
(참고 : ace.c9.io/, github.com/ajaxorg/ace)
반응형