๋งํฌ
์ฝ๋
HTML
<script src="https://uicdn.toast.com/editor/latest/toastui-editor-all.min.js"></script>
<link rel="stylesheet" href="https://uicdn.toast.com/editor/latest/toastui-editor.min.css" />
<!-- ์ ํ์ค ํ์ด๋ผ์ดํฐ ํ๋ฌ๊ทธ์ธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์์ -->
<link rel="stylesheet" href="https://uicdn.toast.com/editor-plugin-code-syntax-highlight/latest/toastui-editor-plugin-code-syntax-highlight.min.css">
<script src="https://uicdn.toast.com/editor-plugin-code-syntax-highlight/latest/toastui-editor-plugin-code-syntax-highlight-all.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism.min.css">
<!-- ์ ํ์ค ํ์ด๋ผ์ดํฐ ํ๋ฌ๊ทธ์ธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ -->
<template id="viewer-1-template">
# ์๋
ํ์ธ์.
## ๋ฐ๊ฐ์์.
- ํํ
- ํธํธ
- ํํ
# ์๋ฐ
```java
// ์ฃผ์์
๋๋ค.
int a = 10;
int b = 20;
System.out.println(a + b);
```
```html
<script src="๊ฒฝ๋ก"></script>
```
</template>
<div id="viewer-1"></div>
CSS
body {
margin: 0;
}
@font-face {
font-family: "GmarketSansMedium";
src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2001@1.1/GmarketSansMedium.woff")
format("woff");
font-weight: normal;
font-style: normal;
}
#viewer-1 {
padding: 0 10px;
}
html > body,
html > body .toastui-editor-contents {
font-family: "GmarketSansMedium";
}
JS
console.clear();
const Editor = toastui.Editor;
// id๊ฐ 'viewer-1-template' ์ธ ์๋ฆฌ๋จผํธ๋ฅผ ์ฐพ๋๋ค.
const viewer1TemplateEl = document.querySelector("#viewer-1-template");
const viewer1MarkdownSource = viewer1TemplateEl.innerHTML; // ํฌํจํ๊ณ ์๋ ๋ด์ฉ
console.log("viewer1MarkdownSource : " + viewer1MarkdownSource);
const viewer1 = Editor.factory({
el: document.querySelector("#viewer-1"),
viewer: true,
initialValue: viewer1MarkdownSource,
plugins: [[toastui.Editor.plugin.codeSyntaxHighlight, { highlighter: Prism }]]
});
์คํ ๊ฒฐ๊ณผ