Skip to content

Commit 8ac0a8b

Browse files
committed
debug
1 parent 46e3776 commit 8ac0a8b

File tree

3 files changed

+44
-34
lines changed

3 files changed

+44
-34
lines changed

index.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,34 @@ function convert(_code, cmdMap1, cmdMap2) {
1717
let code = _code;
1818

1919
for (let i = 0; i < code.length; i++) {
20-
if (cmdMap1[code[i]]) {
21-
code = code.slice(0, i) + cmdMap1[code[i]] + code.slice(i + 1);
22-
}
2320
if (['…', '⋯','⋮'].includes(code[i])) {
2421
code = code.slice(0, i) + '...' + code.slice(i + 1);
2522
}
2623
}
24+
25+
for (const rule of cmdMap1) {
26+
const [regex, dest, symbol] = rule;
27+
28+
let result;
29+
while ((result = regex.exec(code)) !== null) {
30+
const [full, dots] = result;
31+
const { index } = result;
32+
let newCmd = dest;
33+
newCmd += symbol.repeat(dots.length);
34+
code = code.slice(0, index) + newCmd + code.slice(index + full.length);
35+
}
36+
}
2737

2838
for (const rule of cmdMap2) {
29-
const [regex, dest, tilde] = rule;
39+
const [regex, dest, symbol] = rule;
3040
const [st, mid, ed] = dest;
3141

3242
let result;
3343
while ((result = regex.exec(code)) !== null) {
3444
const [full, midOrigin, dots] = result;
3545
const { index } = result;
3646
let newCmd = `${st}${mid.repeat(midOrigin.length)}${ed}`;
37-
newCmd += (tilde ? '~' : '.').repeat(dots.length);
47+
newCmd += symbol.repeat(dots.length);
3848
code = code.slice(0, index) + newCmd + code.slice(index + full.length);
3949
}
4050
}

map.js

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
module.exports = {
2-
h2y1: {
3-
'형': '양',
4-
'항': '먐',
5-
'핫': '냥',
6-
'흣': '굵',
7-
'흡': '꾹',
8-
'흑': '뺩',
9-
},
2+
h2y1: [
3+
[/(\.*)/gm, '양', '~'],
4+
[/(\.*)/gm, '먐', '~'],
5+
[/(\.*)/gm, '냥', '~'],
6+
[/(\.*)/gm, '굵', '.'],
7+
[/(\.*)/gm, '꾹', '.'],
8+
[/(\.*)/gm, '뺩', '.'],
9+
],
1010
h2y2: [
11-
[/(*)(\.*)/gm, ['야', '오', '옹'], true],
12-
[/(*)(\.*)/gm, ['먀', '아', '암'], true],
13-
[/(*)(\.*)/gm, ['냐', '아', '앙'], true],
14-
[/(*)(\.*)/gm, ['구', '루', '룱']],
15-
[/(*)(\.*)/gm, ['꾸', '우', '욱']],
16-
[/(*)(\.*)/gm, ['골', '골', '골']],
11+
[/(*)(\.*)/gm, ['야', '오', '옹'], '~'],
12+
[/(*)(\.*)/gm, ['먀', '아', '암'], '~'],
13+
[/(*)(\.*)/gm, ['냐', '아', '앙'], '~'],
14+
[/(*)(\.*)/gm, ['구', '루', '룱'], '.'],
15+
[/(*)(\.*)/gm, ['꾸', '우', '욱'], '.'],
16+
[/(*)(\.*)/gm, ['골', '골', '골'], '.'],
17+
],
18+
y2h1: [
19+
[/(\~*)/gm, '형', '.'],
20+
[/(\~*)/gm, '항', '.'],
21+
[/(\~*)/gm, '핫', '.'],
22+
[/(\.*)/gm, '흣', '.'],
23+
[/(\.*)/gm, '흡', '.'],
24+
[/(\.*)/gm, '흑', '.'],
1725
],
18-
y2h1: {
19-
'양': '형',
20-
'먐': '항',
21-
'냥': '핫',
22-
'굵': '흣',
23-
'꾹': '흡',
24-
'뺩': '흑',
25-
},
2626
y2h2: [
27-
[/(*)(\~*)/gm, ['혀', '어', '엉']],
28-
[/(*)(\~*)/gm, ['하', '아', '앙']],
29-
[/(*)(\~*)/gm, ['하', '아', '앗']],
30-
[/(*)(\.*)/gm, ['흐', '으', '읏']],
31-
[/(*)(\.*)/gm, ['흐', '으', '읍']],
32-
[/(*)(\.*)/gm, ['흐', '으', '윽']],
27+
[/(*)(\~*)/gm, ['혀', '어', '엉'], '.'],
28+
[/(*)(\~*)/gm, ['하', '아', '앙'], '.'],
29+
[/(*)(\~*)/gm, ['하', '아', '앗'], '.'],
30+
[/(*)(\.*)/gm, ['흐', '으', '읏'], '.'],
31+
[/(*)(\.*)/gm, ['흐', '으', '읍'], '.'],
32+
[/(*)(\.*)/gm, ['흐', '으', '윽'], '.'],
3333
],
3434
}

test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const hyeongnya = require('./index');
22

33
const hyeong = '혀어어어어어어어엉........ 핫. 혀엉..... 흑... 하앗... 흐윽... 형. 하앙. 혀엉.... 하앙... 흐윽... 항. 항. 형... 하앙. 흐으윽... 형... 흡... 혀엉.. 하아아앗. 혀엉.. 흡... 흐읍... 형.. 하앗. 하아앙... 형... 하앙... 흐윽... 혀어어엉.. 하앙. 항. 형... 하앙. 혀엉.... 하앙. 흑... 항. 형... 흡 하앗. 혀엉..... 흑. 흣';
4-
const yaong = '야오오오오오오오옹~~~~~~~~ 냥. 야옹~~~~~ 뺩... 냐앙~~~ 골골... 양. 먀암~ 야옹~~~~ 먀암~~~ 골골... 먐. 먐. 양... 먀암~ 골골골... 양... 꾹... 야옹~~ 냐아아앙~ 야옹~~ 꾹... 꾸욱... 양.. 냐앙~ 먀아암~~~ 양... 먀암~~~ 골골... 야오오옹~~ 먀암~ 먐. 양... 먀암~ 야옹~~~~ 먀암~ 뺩... 먐. 양... 꾹 냐앙~ 야옹~~~~~ 뺩. 굵';
4+
const yaong = '야오오오오오오오옹~~~~~~~~ 냥~ 야옹~~~~~ 뺩... 냐앙~~~ 골골... 양~ 먀암~ 야옹~~~~ 먀암~~~ 골골... 먐~ 먐~ 양~~~ 먀암~ 골골골... 양~~~ 꾹... 야옹~~ 냐아아앙~ 야옹~~ 꾹... 꾸욱... 양~~ 냐앙~ 먀아암~~~ 양~~~ 먀암~~~ 골골... 야오오옹~~ 먀암~ 먐~ 양~~~ 먀암~ 야옹~~~~ 먀암~ 뺩... 먐~ 양~~~ 꾹 냐앙~ 야옹~~~~~ 뺩. 굵';
55

66
try {
77
const convertedYaong = hyeongnya.toYaong(hyeong);

0 commit comments

Comments
 (0)