File tree Expand file tree Collapse file tree 2 files changed +43
-1
lines changed
src/components/InteractiveCodeEditor Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -6,11 +6,29 @@ import Tabs from "@theme/Tabs";
6
6
import TabItem from " @theme/TabItem" ;
7
7
import installTexLive from " ./install_texlive.mov" ;
8
8
import typesetTex from " ./typeset_tex.mp4" ;
9
+ import InteractiveCodeEditor from " @site/src/components/InteractiveCodeEditor/InteractiveCodeEditor" ;
9
10
10
11
# $\LaTeX$ の導入
11
12
12
13
なぜか周りに $\LaTeX$ を使っている人が多いので、$\LaTeX$ 環境の構築方法を解説しておきます。
13
14
15
+ ## LaTeX のプレイグラウンド
16
+
17
+ $\LaTeX$ のプレイグラウンドを作ってみました。機能には制限がありますが、雰囲気は味わえるかと思います。
18
+
19
+ <InteractiveCodeEditor
20
+ language = " latex"
21
+ defaultValue = { ` \
22
+ \\ documentclass{article}
23
+ \\ begin{document}
24
+ Hello World!
25
+ $$
26
+ a^2 + b^2 = c^2
27
+ $$
28
+ \\ end{document}\
29
+ ` }
30
+ ></InteractiveCodeEditor >
31
+
14
32
## TeXLive のインストール
15
33
16
34
[ Visual Studio Code をインストールの項] ( /docs/03extras/02vscode/ ) を参考に VSCode をインストールしておいてください。
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ export default function InteractiveCodeEditor({
14
14
defaultCSS,
15
15
defaultJavaScript,
16
16
} : {
17
- language : "html" | "markdown" | "HTML-CSS-JavaScript" ;
17
+ language : "html" | "markdown" | "HTML-CSS-JavaScript" | "latex" ;
18
18
defaultValue ?: string ;
19
19
defaultHTML ?: string ;
20
20
defaultCSS ?: string ;
@@ -59,6 +59,28 @@ export default function InteractiveCodeEditor({
59
59
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.css"/>
60
60
<link rel="stylesheet" href="https://cdn.jsdelivr.net/github-markdown-css/2.2.1/github-markdown.css"/>
61
61
` ;
62
+
63
+ function latexRender ( value : string ) {
64
+ const header = `\
65
+ <!DOCTYPE html>
66
+ <html lang="ja">
67
+ <head>
68
+ <meta charset="UTF-8" />
69
+ <script type="module">
70
+ import { LaTeXJSComponent } from "https://cdn.jsdelivr.net/npm/latex.js/dist/latex.mjs";
71
+ customElements.define("latex-js", LaTeXJSComponent);
72
+ </script>
73
+ </head>
74
+ <body>
75
+ <latex-js baseURL="https://cdn.jsdelivr.net/npm/latex.js/dist/">\
76
+ ` ;
77
+ const footer = `\
78
+ </latex-js>
79
+ </body>
80
+ </html>\
81
+ ` ;
82
+ return header + value + footer ;
83
+ }
62
84
return (
63
85
< >
64
86
< div className = { styles . playgroundContainer } >
@@ -119,6 +141,8 @@ export default function InteractiveCodeEditor({
119
141
? code
120
142
: language === "markdown"
121
143
? markdownDefaultValue + md . render ( code )
144
+ : language === "latex"
145
+ ? latexRender ( code )
122
146
: `<style>${ css } </style>${ html } <script>${ js } </script>`
123
147
}
124
148
title = "Live Code"
You can’t perform that action at this time.
0 commit comments