Skip to content

Commit 6c5e532

Browse files
committed
파싱 무시 영역 추가 및 Readme 갱신
1 parent a797a2f commit 6c5e532

9 files changed

Lines changed: 374 additions & 20 deletions

File tree

CSharp-Multilingual-Markdown-Generator/.vs/CSharp-Multilingual-Markdown-Generator/FileContentIndex/read.lock

Whitespace-only changes.
Binary file not shown.

CSharp-Multilingual-Markdown-Generator/MarkDownParser.cs

Lines changed: 68 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,41 @@ public enum LanguageType
4343
}
4444

4545
private const string KeyLanguageStart = "<!--";
46-
private const string KeyEn = "<!--[en-us]-->";
47-
private const string KeyKo = "<!--[ko-kr]-->";
48-
private const string KeyJp = "<!--[ja-jp]-->";
49-
private const string KeyFr = "<!--[fr-fr]-->";
46+
private const string KeyEn = "<!--[en]-->";
47+
private const string KeyKr = "<!--[kr]-->";
48+
private const string KeyJp = "<!--[ja]-->";
49+
private const string KeyFr = "<!--[fr]-->";
50+
51+
private const string KeyEnFull = "<!--[en-us]-->";
52+
private const string KeyKrFull = "<!--[ko-kr]-->";
53+
private const string KeyJpFull = "<!--[ja-jp]-->";
54+
private const string KeyFrFull = "<!--[fr-fr]-->";
55+
5056
private const string KeyCommon = "<!--[common]-->";
5157
private const string KeyIgonre = "<!--[ignore]-->";
5258
private const string KeyLink = "<!--[document_link]-->";
5359

60+
private const string KeyIgonoreParse = "```";
61+
5462
private Dictionary<LanguageType, bool> _usingLanguage = new Dictionary<LanguageType, bool>();
5563
private Dictionary<LanguageType, StringBuilder> _dataDic = new Dictionary<LanguageType, StringBuilder>();
5664
private Dictionary<LanguageType, LanguageInformation> _infoDic = new Dictionary<LanguageType, LanguageInformation>();
5765
private string _baseFileName;
66+
private bool _igonoreParse;
67+
68+
5869

5970
private void Init()
6071
{
72+
_igonoreParse = false;
6173
_infoDic.Clear();
6274
_usingLanguage.Clear();
6375
_dataDic.Clear();
6476

65-
_infoDic.Add(LanguageType.Kr, new LanguageInformation(LanguageType.Kr, "ko-KR", "한국어"));
66-
_infoDic.Add(LanguageType.En, new LanguageInformation(LanguageType.En, "en-US", "English"));
67-
_infoDic.Add(LanguageType.Jp, new LanguageInformation(LanguageType.Jp, "ja-JP", "日本語"));
68-
_infoDic.Add(LanguageType.Fr, new LanguageInformation(LanguageType.Fr, "fr-FR", "Français"));
77+
_infoDic.Add(LanguageType.Kr, new LanguageInformation(LanguageType.Kr, "kr", "한국어"));
78+
_infoDic.Add(LanguageType.En, new LanguageInformation(LanguageType.En, "en", "English"));
79+
_infoDic.Add(LanguageType.Jp, new LanguageInformation(LanguageType.Jp, "ja", "日本語"));
80+
_infoDic.Add(LanguageType.Fr, new LanguageInformation(LanguageType.Fr, "fr", "Français"));
6981
}
7082

7183

@@ -114,6 +126,24 @@ public void GenerateDocument(string filePath, string baseFileName, LanguageType
114126

115127
private CommandType ParaseCommand(string line)
116128
{
129+
if(line == KeyIgonoreParse)
130+
{
131+
if(!_igonoreParse)
132+
{
133+
_igonoreParse = true;
134+
return CommandType.None;
135+
}
136+
else
137+
{
138+
_igonoreParse = false;
139+
}
140+
}
141+
142+
if(_igonoreParse)
143+
{
144+
return CommandType.None;
145+
}
146+
117147
if (line == KeyIgonre)
118148
{
119149
return CommandType.Igonore;
@@ -137,15 +167,19 @@ private LanguageType ParseLanguage(string line)
137167
switch (line)
138168
{
139169
case KeyEn:
170+
case KeyEnFull:
140171
return LanguageType.En;
141172

142-
case KeyKo:
173+
case KeyKr:
174+
case KeyKrFull:
143175
return LanguageType.Kr;
144176

145177
case KeyJp:
178+
case KeyJpFull:
146179
return LanguageType.Jp;
147180

148181
case KeyFr:
182+
case KeyFrFull:
149183
return LanguageType.Fr;
150184

151185
case KeyCommon:
@@ -163,25 +197,49 @@ private void InitializeLanguage(string[] lines)
163197
{
164198
string line = readLine.Replace(" ", "").ToLower();
165199

200+
if (line == KeyIgonoreParse)
201+
{
202+
if (!_igonoreParse)
203+
{
204+
_igonoreParse = true;
205+
continue;
206+
}
207+
else
208+
{
209+
_igonoreParse = false;
210+
}
211+
}
212+
213+
if(_igonoreParse)
214+
{
215+
continue;
216+
}
217+
166218
switch (line)
167219
{
168220
case KeyEn:
221+
case KeyEnFull:
169222
_usingLanguage[LanguageType.En] = true;
170223
break;
171224

172-
case KeyKo:
225+
case KeyKr:
226+
case KeyKrFull:
173227
_usingLanguage[LanguageType.Kr] = true;
174228
break;
175229

176230
case KeyJp:
231+
case KeyJpFull:
177232
_usingLanguage[LanguageType.Jp] = true;
178233
break;
179234

180235
case KeyFr:
236+
case KeyFrFull:
181237
_usingLanguage[LanguageType.Fr] = true;
182238
break;
183239
}
184240
}
241+
242+
_igonoreParse = false;
185243
}
186244

187245
private void ParseLines(string[] lines)

README.base.md

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# CSharp-Multilingual-Markdown-Generator
2+
3+
<!--[document_link]-->
4+
<!--[kr]-->
5+
다국어 마크다운 문서 생성기
6+
7+
이 프로젝트는 ryul1206님의 multilingual-markdown 프로젝트를 기반으로 만들어 졌습니다.
8+
<!--[en]-->
9+
Multilingual Markdown Generator
10+
11+
This project is based on ryul1206's multilingual-markdown project.
12+
<!--[common]-->
13+
14+
[Link : https://github.com/ryul1206/multilingual-markdown ](https://github.com/ryul1206/multilingual-markdown)
15+
16+
<!--[kr]-->
17+
## 개요
18+
코드 키워드를 이용해 각 언어별 문서를 생성해줍니다.
19+
<!--[en]-->
20+
## Overview
21+
It creates documents for each language using code keywords.
22+
23+
<!--[kr]-->
24+
## 사용법
25+
<!--[en]-->
26+
## How to Use
27+
<!--[kr]-->
28+
### 파일 규칙
29+
<!--[en]-->
30+
### File Rule
31+
<!--[kr]-->
32+
{FileName}.base.md 으로 되어 있어야 합니다. 예시는 [example.base.md](example/example.base.md)을 보시면 됩니다
33+
34+
ex : Readme.base.md
35+
<!--[en]-->
36+
It should be {FileName}.base.md . For an example, see this documnet [example.base.md](example/example.base.md)
37+
38+
ex : Readme.base.md
39+
40+
<!--[kr]-->
41+
### 문서 생성
42+
<!--[en]-->
43+
### Generate Documnet
44+
<!--[kr]-->
45+
문서 생성 / Generate 버튼을 이용해 파일을 선택후 만듭니다
46+
<!--[en]-->
47+
Use '문서 생성 / Generate' button to select a file and create it
48+
49+
<!--[kr]-->
50+
### 주 언어 설정
51+
<!--[en]-->
52+
### Select Main Language
53+
<!--[kr]-->
54+
주 언어 / Main Language 의 라디오 버튼을 이용해 주 언어를 설정합니다.
55+
주 언어로 선택된 언어는 파일 이름에서 .base. 가 제거되어서 나옵니다
56+
57+
(ex :Readme.base.md -> Readme.md)
58+
<!--[en]-->
59+
Use '주 언어 / Main Language' radio button to set the primary language.
60+
The language selected as the primary language is the .base. is removed and comes out
61+
62+
(ex :Readme.base.md -> Readme.md)
63+
64+
65+
<!--[kr]-->
66+
## 코드 키워드
67+
<!--[en]-->
68+
## Code Keyword
69+
<!--[kr]-->
70+
**언어 키워드**
71+
72+
<!--[en]-->
73+
**Language Keyword**
74+
75+
<!--[kr]-->
76+
언어별 텍스트 영역을 구분하는 키워드입니다.
77+
언어 키워드를 인식한 후 다음 언어 키워드나 공통 영역 키워드를 만날때가지 해당 언어로 처리됩니다.
78+
79+
아래는 현재 지원하는 언어입니다
80+
<!--[en]-->
81+
A keyword that separates language-specific text areas.
82+
After recognizing a language keyword, it is processed in that language until the next language keyword or common area keyword is encountered.
83+
84+
currently supported language list
85+
<!--[common]-->
86+
```
87+
<!-- [en] -->
88+
<!-- [kr] -->
89+
<!-- [fr] -->
90+
<!-- [jp] -->
91+
```
92+
93+
<!--[kr]-->
94+
**공통 영역**
95+
96+
<!--[en]-->
97+
**Common Area**
98+
99+
<!--[kr]-->
100+
모든 언어에 공통으로 들어갈 텍스트 영역을 구분하는 키워드입니다.
101+
<!--[en]-->
102+
A keyword that delimits a text area common to all languages.
103+
104+
<!-- [common] -->
105+
```
106+
<!-- [common] -->
107+
```
108+
109+
110+
<!--[kr]-->
111+
**무시 영역**
112+
113+
<!--[en]-->
114+
**Igonore Area**
115+
116+
<!--[kr]-->
117+
주석용으로 쓰는 영역입니다. 이 영역에 지정된 텍스트는 파일에 포함되지 않습니다
118+
<!--[en]-->
119+
This area is used for comments. Text specified in this area will not be included in the file
120+
121+
<!-- [common] -->
122+
```
123+
<!-- [ignore] -->
124+
```
125+
126+
127+
<!--[kr]-->
128+
**언어 링크 키워드**
129+
130+
<!--[en]-->
131+
**Language Link**
132+
133+
134+
<!--[kr]-->
135+
이 키워드가 있는 곳는 언어별 문서 링크 텍스트로 대체됩니다. 문서에 포함된 언어를 자동으로 링크해 줍니다
136+
<!--[en]-->
137+
Wherever this keyword appears, it will be replaced with the language-specific document link text.
138+
Automatically links to languages embedded in documents
139+
140+
<!-- [common] -->
141+
```
142+
<!-- [document_link] -->
143+
```
144+
145+
146+
147+
148+
149+
150+
151+
152+

README.en.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# CSharp-Multilingual-Markdown-Generator
2+
3+
🌏[한국어](README.kr.md) | [English](README.en.md)
4+
5+
6+
Multilingual Markdown Generator
7+
8+
This project is based on ryul1206's multilingual-markdown project.
9+
10+
[Link : https://github.com/ryul1206/multilingual-markdown ](https://github.com/ryul1206/multilingual-markdown)
11+
12+
## Overview
13+
It creates documents for each language using code keywords.
14+
15+
## How to Use
16+
### File Rule
17+
It should be {FileName}.base.md . For an example, see this documnet [example.base.md](example/example.base.md)
18+
19+
ex : Readme.base.md
20+
21+
### Generate Documnet
22+
Use '문서 생성 / Generate' button to select a file and create it
23+
24+
### Select Main Language
25+
Use '주 언어 / Main Language' radio button to set the primary language.
26+
The language selected as the primary language is the .base. is removed and comes out
27+
28+
(ex :Readme.base.md -> Readme.md)
29+
30+
31+
## Code Keyword
32+
**Language Keyword**
33+
34+
A keyword that separates language-specific text areas.
35+
After recognizing a language keyword, it is processed in that language until the next language keyword or common area keyword is encountered.
36+
37+
currently supported language list
38+
```
39+
<!-- [en] -->
40+
<!-- [kr] -->
41+
<!-- [fr] -->
42+
<!-- [jp] -->
43+
```
44+
45+
**Common Area**
46+
47+
A keyword that delimits a text area common to all languages.
48+
49+
```
50+
<!-- [common] -->
51+
```
52+
53+
54+
**Igonore Area**
55+
56+
This area is used for comments. Text specified in this area will not be included in the file
57+
58+
```
59+
<!-- [ignore] -->
60+
```
61+
62+
63+
**Language Link**
64+
65+
66+
Wherever this keyword appears, it will be replaced with the language-specific document link text.
67+
Automatically links to languages embedded in documents
68+
69+
```
70+
<!-- [document_link] -->
71+
```
72+
73+
74+
75+
76+
77+
78+
79+
80+

0 commit comments

Comments
 (0)