add korean replace list
This commit is contained in:
parent
ca3c6f27a5
commit
8d3d55601d
1 changed files with 98 additions and 5 deletions
|
|
@ -10,11 +10,11 @@ export const IsolatedSymbolMap = {
|
||||||
}
|
}
|
||||||
export const SymbolMap = {
|
export const SymbolMap = {
|
||||||
"%": "퍼센트",
|
"%": "퍼센트",
|
||||||
"$": "달러싸인",
|
"$": "달러",
|
||||||
"^": "캐럿",
|
"^": "캐럿",
|
||||||
"&": "엠퍼센드",
|
"&": "엔드",
|
||||||
"*": "스타",
|
"*": "스타",
|
||||||
"#": "해시",
|
"#": "샵",
|
||||||
"@": "엣",
|
"@": "엣",
|
||||||
".": "쩜",
|
".": "쩜",
|
||||||
"-": "마이너스",
|
"-": "마이너스",
|
||||||
|
|
@ -22,14 +22,87 @@ export const SymbolMap = {
|
||||||
"_": "언더바",
|
"_": "언더바",
|
||||||
"=": "이퀄",
|
"=": "이퀄",
|
||||||
"/": "슬래쉬",
|
"/": "슬래쉬",
|
||||||
|
"~": "물결표",
|
||||||
"\\": "역슬래쉬",
|
"\\": "역슬래쉬",
|
||||||
"♡": "하투 ",
|
"♡": "하트 ",
|
||||||
};
|
};
|
||||||
export const VersionPostfix = {
|
export const VersionPostfix = {
|
||||||
"a": "알파",
|
"a": "알파",
|
||||||
"b": "베타",
|
"b": "베타",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const LangPrefixs = {
|
||||||
|
"typescript": "타입스크립트",
|
||||||
|
"javascript": "자바스크립트",
|
||||||
|
"java": "자바",
|
||||||
|
"kotlin": "코틀린",
|
||||||
|
"rust": "러스트",
|
||||||
|
"lua": "루아",
|
||||||
|
"json": "제이슨",
|
||||||
|
"yaml": "야믈",
|
||||||
|
"yml": "야믈",
|
||||||
|
"toml": "토믈",
|
||||||
|
"julia": "줄리아",
|
||||||
|
"matlab": "매트랩",
|
||||||
|
"erlang": "얼랭",
|
||||||
|
"elxir": "엘릭서",
|
||||||
|
|
||||||
|
"cpp": "씨플플",
|
||||||
|
"c++": "씨플플",
|
||||||
|
"csharp": "씨샵",
|
||||||
|
"cs": "씨샵",
|
||||||
|
"c#": "씨샵",
|
||||||
|
"c": "씨",
|
||||||
|
|
||||||
|
"pwsh": "파워쉘",
|
||||||
|
"powershell": "파워쉘",
|
||||||
|
"cmd": "씨엠디",
|
||||||
|
"sh": "쉘",
|
||||||
|
"ps1": "파워셀",
|
||||||
|
"bat": "배치파일",
|
||||||
|
"bash": "베시스크립트",
|
||||||
|
"tex": "텍",
|
||||||
|
|
||||||
|
"latex": "레이텍",
|
||||||
|
"md": "마크다운",
|
||||||
|
"markdown": "마크다운",
|
||||||
|
|
||||||
|
"rs": "러스트",
|
||||||
|
"kt": "코틀린",
|
||||||
|
"js": "자바스크립트",
|
||||||
|
"ts": "타입스크립트",
|
||||||
|
"tsx": "리액트 타입스크립트",
|
||||||
|
"jsx": "리액트 자바스크립트",
|
||||||
|
};
|
||||||
|
export const ChoseongMap = {
|
||||||
|
"ㄱ": "기역",
|
||||||
|
"ㄴ": "니은",
|
||||||
|
"ㄷ": "디귿",
|
||||||
|
"ㄹ": "리을",
|
||||||
|
"ㅁ": "미음",
|
||||||
|
"ㅂ": "비읍",
|
||||||
|
"ㅅ": "시옷",
|
||||||
|
"ㅇ": "이응",
|
||||||
|
"ㅈ": "지읒",
|
||||||
|
"ㅊ": "치읓",
|
||||||
|
"ㅋ": "키읔",
|
||||||
|
"ㅌ": "티읕",
|
||||||
|
"ㅍ": "피읖",
|
||||||
|
"ㅎ": "히읗",
|
||||||
|
"ㄲ": "쌍기역",
|
||||||
|
"ㄸ": "쌍디귿",
|
||||||
|
"ㅃ": "쌍비읍",
|
||||||
|
"ㅆ": "쌍시옷",
|
||||||
|
"ㅉ": "쌍지읒",
|
||||||
|
};
|
||||||
|
export const LangPrefixMaxLength = (()=>{
|
||||||
|
let max = 0;
|
||||||
|
for (const key in LangPrefixs) {
|
||||||
|
max = Math.max(key.length, max);
|
||||||
|
}
|
||||||
|
return max;
|
||||||
|
})();
|
||||||
|
|
||||||
export function saferKorean(input: string): string {
|
export function saferKorean(input: string): string {
|
||||||
return input.replace(/\.+$/, "")
|
return input.replace(/\.+$/, "")
|
||||||
.replace(/\.\.+/g, "")
|
.replace(/\.\.+/g, "")
|
||||||
|
|
@ -39,8 +112,27 @@ export function saferKorean(input: string): string {
|
||||||
element as keyof typeof IsolatedSymbolMap
|
element as keyof typeof IsolatedSymbolMap
|
||||||
]).join("")
|
]).join("")
|
||||||
))
|
))
|
||||||
.replace(/\`\`\`.+?\`\`\`/g, "코드블럭")
|
.replace(/\`\`\`([\s\S]*?)\`\`\`/g, (_, content: string)=>{
|
||||||
|
const code = content.substring(0, LangPrefixMaxLength).toLowerCase();
|
||||||
|
let lang = "";
|
||||||
|
for (const [key, value] of Object.entries(LangPrefixs)) {
|
||||||
|
if (code.startsWith(key + "\n")) {
|
||||||
|
lang = value + " ";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lang + "코드블럭";
|
||||||
|
})
|
||||||
|
.replace(/ㅋ{2,}/g, "크")
|
||||||
|
.replace(/[아ㅏ]{3,}/g, "아아아")
|
||||||
.replace(/https\S+/g, "링크")
|
.replace(/https\S+/g, "링크")
|
||||||
|
.replace(/ㅌ{2,}/g, "틔틔")
|
||||||
|
.replace(/ㄱ+/g, (content: string) => {
|
||||||
|
if (content.length == 2) {
|
||||||
|
return "고고";
|
||||||
|
}
|
||||||
|
return content;
|
||||||
|
})
|
||||||
.replace(/(\d+)[ \t\n]*([개살])/g, (_, num: string, postfix: string)=>{
|
.replace(/(\d+)[ \t\n]*([개살])/g, (_, num: string, postfix: string)=>{
|
||||||
const intNum = parseInt(num)
|
const intNum = parseInt(num)
|
||||||
if (CallingNumberKorean.canConvert(intNum)) {
|
if (CallingNumberKorean.canConvert(intNum)) {
|
||||||
|
|
@ -49,6 +141,7 @@ export function saferKorean(input: string): string {
|
||||||
return IntegerKorean.convertFromString(num) + postfix;
|
return IntegerKorean.convertFromString(num) + postfix;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.replace(/[ㄱ-ㅎㄲㄸㅃㅆㅉ]/g, (char: string) => ChoseongMap[char as keyof typeof ChoseongMap])
|
||||||
.replace(/(v?)([\d\.]+)([ab]?)/g, (_, suffix: string, num: string, postfix: string) => {
|
.replace(/(v?)([\d\.]+)([ab]?)/g, (_, suffix: string, num: string, postfix: string) => {
|
||||||
const dotCount = [...num.matchAll(/\./g)].length;
|
const dotCount = [...num.matchAll(/\./g)].length;
|
||||||
const hasNoSuffix = suffix == "";
|
const hasNoSuffix = suffix == "";
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue