<!DOCTYPE html>
<html lang="zh-CN">
<head>
<title>ACE in Action</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div style="display: flex; height: 40vh;">
<div style="flex: 50%">
<div id="editor" style="width: 100%; height: 100%;"># ACE in Action</div>
</div>
<div style="flex: 50%">
<div id="previewer" style="width: 100%; height: 100%; overflow: scroll;"></div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.35.4/ace.min.js" type="text/javascript"
charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/14.0.0/marked.min.js" type="text/javascript"
charset="utf-8"></script>
<script>
var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.session.setMode("ace/mode/markdown");
editor.session.on('change', function (delta) {
const content = editor.getValue();
document.querySelector("#previewer").innerHTML = marked.marked(content);
});
</script>
</body>
</html>
标签:markdown,预览,ACE,content,ace,session,editor
From: https://www.cnblogs.com/soarowl/p/18350247