@@ -2,16 +2,12 @@ import Markdown, { Components, ExtraProps } from "react-markdown";
22import remarkGfm from "remark-gfm" ;
33import removeComments from "remark-remove-comments" ;
44import remarkCjkFriendly from "remark-cjk-friendly" ;
5- import { EditorComponent , getAceLang } from "@/terminal/editor" ;
5+ import { EditorComponent } from "@/terminal/editor" ;
66import { ExecFile } from "@/terminal/exec" ;
77import { JSX , ReactNode } from "react" ;
8- import { getRuntimeLang } from "@/terminal/ runtime" ;
8+ import { langConstants , MarkdownLang } from "@my-code/ runtime/languages " ;
99import { ReplTerminal } from "@/terminal/repl" ;
10- import {
11- getSyntaxHighlighterLang ,
12- MarkdownLang ,
13- StyledSyntaxHighlighter ,
14- } from "./styledSyntaxHighlighter" ;
10+ import { StyledSyntaxHighlighter } from "./styledSyntaxHighlighter" ;
1511
1612export function StyledMarkdown ( { content } : { content : string } ) {
1713 return (
@@ -93,7 +89,7 @@ function CodeComponent({
9389 className || ""
9490 ) ;
9591 if ( match ) {
96- const runtimeLang = getRuntimeLang ( match [ 1 ] as MarkdownLang | undefined ) ;
92+ const language = langConstants ( match [ 1 ] as MarkdownLang | undefined ) ;
9793 if ( match [ 2 ] === "-exec" && match [ 3 ] ) {
9894 /*
9995 ```python-exec:main.py
@@ -105,10 +101,10 @@ function CodeComponent({
105101 hello, world!
106102 ---------------------------
107103 */
108- if ( runtimeLang ) {
104+ if ( language . runtime ) {
109105 return (
110106 < ExecFile
111- language = { runtimeLang }
107+ language = { language }
112108 filenames = { match [ 3 ] . split ( "," ) }
113109 content = { String ( props . children || "" ) . replace ( / \n $ / , "" ) }
114110 />
@@ -121,39 +117,35 @@ function CodeComponent({
121117 `${ match [ 1 ] } -repl without terminal id! content: ${ String ( props . children ) . slice ( 0 , 20 ) } ...`
122118 ) ;
123119 }
124- if ( runtimeLang ) {
120+ if ( language . runtime ) {
125121 return (
126122 < ReplTerminal
127123 terminalId = { match [ 3 ] }
128- language = { runtimeLang }
124+ language = { language }
129125 initContent = { String ( props . children || "" ) . replace ( / \n $ / , "" ) }
130126 />
131127 ) ;
132128 }
133129 } else if ( match [ 3 ] ) {
134130 // ファイル名指定がある場合、ファイルエディター
135- const aceLang = getAceLang ( match [ 1 ] as MarkdownLang | undefined ) ;
136131 return (
137132 < EditorComponent
138- language = { aceLang }
133+ language = { language }
139134 filename = { match [ 3 ] }
140135 readonly = { match [ 2 ] === "-readonly" }
141136 initContent = { String ( props . children || "" ) . replace ( / \n $ / , "" ) }
142137 />
143138 ) ;
144139 }
145- const syntaxHighlighterLang = getSyntaxHighlighterLang (
146- match [ 1 ] as MarkdownLang | undefined
147- ) ;
148140 return (
149- < StyledSyntaxHighlighter language = { syntaxHighlighterLang } >
141+ < StyledSyntaxHighlighter language = { language } >
150142 { String ( props . children || "" ) . replace ( / \n $ / , "" ) }
151143 </ StyledSyntaxHighlighter >
152144 ) ;
153145 } else if ( String ( props . children ) . includes ( "\n" ) ) {
154146 // 言語指定なしコードブロック
155147 return (
156- < StyledSyntaxHighlighter language = { undefined } >
148+ < StyledSyntaxHighlighter language = { langConstants ( undefined ) } >
157149 { String ( props . children || "" ) . replace ( / \n $ / , "" ) }
158150 </ StyledSyntaxHighlighter >
159151 ) ;
@@ -171,4 +163,4 @@ export function InlineCode({ children }: { children: ReactNode }) {
171163 { children }
172164 </ code >
173165 ) ;
174- }
166+ }
0 commit comments