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";
21
21
import Hooks from "../hooks" ;
22
22
import { ErrorFallback } from "./error_handler" ;
23
23
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
+
24
46
const CustomMDXComponents : MDXComponents = {
25
47
h1 : ( props ) => < h1 { ...props } /> ,
26
48
h2 : ( props ) => < h2 { ...props } /> ,
@@ -51,9 +73,11 @@ const lineFormatterForMDX = (line: string) => {
51
73
52
74
if ( R . isEmpty ( trimmedLine ) ) return "\n" ;
53
75
54
- // import문을 위한 꼼수 - import문 다음 줄은 반드시 빈 줄이어야 합니다.
76
+ // import / export / const문을 위한 꼼수 - import문 다음 줄은 반드시 빈 줄이어야 합니다.
55
77
// 그러나 \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
+ }
57
81
58
82
// Table인 경우, 뒤에 공백을 추가하지 않습니다.
59
83
if ( trimmedLine . startsWith ( "|" ) && trimmedLine . endsWith ( "|" ) ) return `${ trimmedLine } \n` ;
You can’t perform that action at this time.
0 commit comments