@@ -5,12 +5,9 @@ import remarkCjkFriendly from "remark-cjk-friendly";
55import { EditorComponent } from "@/terminal/editor" ;
66import { ExecFile } from "@/terminal/exec" ;
77import { JSX , ReactNode } from "react" ;
8- import { getAceLang , getRuntimeLang , MarkdownLang } from "@my-code/runtime/languages" ;
8+ import { langConstants , MarkdownLang } from "@my-code/runtime/languages" ;
99import { ReplTerminal } from "@/terminal/repl" ;
10- import {
11- getSyntaxHighlighterLang ,
12- StyledSyntaxHighlighter ,
13- } from "./styledSyntaxHighlighter" ;
10+ import { StyledSyntaxHighlighter } from "./styledSyntaxHighlighter" ;
1411
1512export function StyledMarkdown ( { content } : { content : string } ) {
1613 return (
@@ -92,7 +89,7 @@ function CodeComponent({
9289 className || ""
9390 ) ;
9491 if ( match ) {
95- const runtimeLang = getRuntimeLang ( match [ 1 ] as MarkdownLang | undefined ) ;
92+ const language = langConstants ( match [ 1 ] as MarkdownLang | undefined ) ;
9693 if ( match [ 2 ] === "-exec" && match [ 3 ] ) {
9794 /*
9895 ```python-exec:main.py
@@ -104,10 +101,10 @@ function CodeComponent({
104101 hello, world!
105102 ---------------------------
106103 */
107- if ( runtimeLang ) {
104+ if ( language . runtime ) {
108105 return (
109106 < ExecFile
110- language = { runtimeLang }
107+ language = { language }
111108 filenames = { match [ 3 ] . split ( "," ) }
112109 content = { String ( props . children || "" ) . replace ( / \n $ / , "" ) }
113110 />
@@ -120,39 +117,35 @@ function CodeComponent({
120117 `${ match [ 1 ] } -repl without terminal id! content: ${ String ( props . children ) . slice ( 0 , 20 ) } ...`
121118 ) ;
122119 }
123- if ( runtimeLang ) {
120+ if ( language . runtime ) {
124121 return (
125122 < ReplTerminal
126123 terminalId = { match [ 3 ] }
127- language = { runtimeLang }
124+ language = { language }
128125 initContent = { String ( props . children || "" ) . replace ( / \n $ / , "" ) }
129126 />
130127 ) ;
131128 }
132129 } else if ( match [ 3 ] ) {
133130 // ファイル名指定がある場合、ファイルエディター
134- const aceLang = getAceLang ( match [ 1 ] as MarkdownLang | undefined ) ;
135131 return (
136132 < EditorComponent
137- language = { aceLang }
133+ language = { language }
138134 filename = { match [ 3 ] }
139135 readonly = { match [ 2 ] === "-readonly" }
140136 initContent = { String ( props . children || "" ) . replace ( / \n $ / , "" ) }
141137 />
142138 ) ;
143139 }
144- const syntaxHighlighterLang = getSyntaxHighlighterLang (
145- match [ 1 ] as MarkdownLang | undefined
146- ) ;
147140 return (
148- < StyledSyntaxHighlighter language = { syntaxHighlighterLang } >
141+ < StyledSyntaxHighlighter language = { language } >
149142 { String ( props . children || "" ) . replace ( / \n $ / , "" ) }
150143 </ StyledSyntaxHighlighter >
151144 ) ;
152145 } else if ( String ( props . children ) . includes ( "\n" ) ) {
153146 // 言語指定なしコードブロック
154147 return (
155- < StyledSyntaxHighlighter language = { undefined } >
148+ < StyledSyntaxHighlighter language = { langConstants ( undefined ) } >
156149 { String ( props . children || "" ) . replace ( / \n $ / , "" ) }
157150 </ StyledSyntaxHighlighter >
158151 ) ;
@@ -170,4 +163,4 @@ export function InlineCode({ children }: { children: ReactNode }) {
170163 { children }
171164 </ code >
172165 ) ;
173- }
166+ }
0 commit comments