File tree Expand file tree Collapse file tree 1 file changed +26
-2
lines changed
packages/common/src/components Expand file tree Collapse file tree 1 file changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,28 @@ import * as R from "remeda";
2121import Hooks from "../hooks" ;
2222import { ErrorFallback } from "./error_handler" ;
2323
24+ const REGISTERED_KEYWORDS = [
25+ "import" ,
26+ "export" ,
27+ "const" ,
28+ "let" ,
29+ "function" ,
30+ "class" ,
31+ "if" ,
32+ "else" ,
33+ "for" ,
34+ "while" ,
35+ "return" ,
36+ "switch" ,
37+ "case" ,
38+ "break" ,
39+ "continue" ,
40+ "," ,
41+ ";" ,
42+ "{" ,
43+ "}" ,
44+ ] ;
45+
2446const CustomMDXComponents : MDXComponents = {
2547 h1 : ( props ) => < h1 { ...props } /> ,
2648 h2 : ( props ) => < h2 { ...props } /> ,
@@ -51,9 +73,11 @@ const lineFormatterForMDX = (line: string) => {
5173
5274 if ( R . isEmpty ( trimmedLine ) ) return "\n" ;
5375
54- // import문을 위한 꼼수 - import문 다음 줄은 반드시 빈 줄이어야 합니다.
76+ // import / export / const문을 위한 꼼수 - import문 다음 줄은 반드시 빈 줄이어야 합니다.
5577 // 그러나 \n\n으로 변환할 경우, 다음 단계에서 <br />로 변환되므로, import문 다음에 공백이 있는 줄을 넣어서 <br />로 변환되지 않도록 합니다.
56- if ( trimmedLine . startsWith ( "import" ) ) return `${ trimmedLine } \n \n` ;
78+ if ( REGISTERED_KEYWORDS . some ( ( keyword ) => trimmedLine . startsWith ( keyword ) || trimmedLine . endsWith ( keyword ) ) ) {
79+ return `${ trimmedLine } \n \n` ;
80+ }
5781
5882 // Table인 경우, 뒤에 공백을 추가하지 않습니다.
5983 if ( trimmedLine . startsWith ( "|" ) && trimmedLine . endsWith ( "|" ) ) return `${ trimmedLine } \n` ;
You can’t perform that action at this time.
0 commit comments