add 1,000 원 replace to 천원
This commit is contained in:
parent
2e6483a36e
commit
8c793863aa
1 changed files with 21 additions and 4 deletions
|
|
@ -130,11 +130,14 @@ export function processDots(input: string): string {
|
||||||
|
|
||||||
export function saferKorean(input: string): string {
|
export function saferKorean(input: string): string {
|
||||||
return processDots(input)
|
return processDots(input)
|
||||||
|
// Process isolated symbols
|
||||||
.replace(/^[\?\!\'\"]+$/, (total)=>(
|
.replace(/^[\?\!\'\"]+$/, (total)=>(
|
||||||
[...total].map(element => IsolatedSymbolMap[
|
[...total].map(element => IsolatedSymbolMap[
|
||||||
element as keyof typeof IsolatedSymbolMap
|
element as keyof typeof IsolatedSymbolMap
|
||||||
]).join("")
|
]).join("")
|
||||||
))
|
))
|
||||||
|
|
||||||
|
// Process codeblock
|
||||||
.replace(/\`\`\`([\s\S]*?)\`\`\`/g, (_, content: string)=>{
|
.replace(/\`\`\`([\s\S]*?)\`\`\`/g, (_, content: string)=>{
|
||||||
const code = content.substring(0, LangPrefixMaxLength).toLowerCase();
|
const code = content.substring(0, LangPrefixMaxLength).toLowerCase();
|
||||||
let lang = "";
|
let lang = "";
|
||||||
|
|
@ -146,6 +149,8 @@ export function saferKorean(input: string): string {
|
||||||
}
|
}
|
||||||
return lang + "코드블럭";
|
return lang + "코드블럭";
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Process koreans
|
||||||
.replace(/ㅋ{2,}/g, (content) => "크".repeat(content.length))
|
.replace(/ㅋ{2,}/g, (content) => "크".repeat(content.length))
|
||||||
.replace(/[아ㅏ]{3,}/g, "아아아")
|
.replace(/[아ㅏ]{3,}/g, "아아아")
|
||||||
.replace(/https\S+/g, "링크")
|
.replace(/https\S+/g, "링크")
|
||||||
|
|
@ -158,12 +163,17 @@ export function saferKorean(input: string): string {
|
||||||
}
|
}
|
||||||
return content;
|
return content;
|
||||||
})
|
})
|
||||||
|
.replace(/[ㄱ-ㅎㄲㄸㅃㅆㅉ]/g, (char: string) => ChoseongMap[char as keyof typeof ChoseongMap])
|
||||||
|
|
||||||
|
// Process number, unit
|
||||||
.replace(/(\d+)([kKMmgGtTpP][iI]?)[bB]/g, (_, num: string, mod: string) => {
|
.replace(/(\d+)([kKMmgGtTpP][iI]?)[bB]/g, (_, num: string, mod: string) => {
|
||||||
|
// 10kib => 10키비바이트
|
||||||
num = IntegerKorean.convertFromString(num);
|
num = IntegerKorean.convertFromString(num);
|
||||||
mod = SIPrefix[mod.toLowerCase() as keyof typeof SIPrefix];
|
mod = SIPrefix[mod.toLowerCase() as keyof typeof SIPrefix];
|
||||||
return `${num} ${mod}바이트 `;
|
return `${num} ${mod}바이트 `;
|
||||||
})
|
})
|
||||||
.replace(/([\d.]+)[ \t\n]*([개살시평명])/g, (_, num: string, postfix: string)=>{
|
.replace(/([\d\.]+)[ \t\n]*([개살시평명])/g, (_, num: string, postfix: string)=>{
|
||||||
|
// 10명 => 열명
|
||||||
if (num.includes(".")) {
|
if (num.includes(".")) {
|
||||||
return num + postfix;
|
return num + postfix;
|
||||||
}
|
}
|
||||||
|
|
@ -174,7 +184,12 @@ 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(/[\d,]+/g, (num: string) => {
|
||||||
|
// 1,000 원 => 천원
|
||||||
|
if (!num.includes(",")) return num;
|
||||||
|
num = num.replace(/,/g, "");
|
||||||
|
return IntegerKorean.convertFromString(num);
|
||||||
|
})
|
||||||
.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 == "";
|
||||||
|
|
@ -206,10 +221,12 @@ export function saferKorean(input: string): string {
|
||||||
return FloatKorean.convert(num) + postfix;
|
return FloatKorean.convert(num) + postfix;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.replace(/㎡/g, "제곱미터")
|
||||||
|
.replace(/㎢/g, "제곱킬로미터")
|
||||||
|
|
||||||
|
// Process symbol
|
||||||
.replace(/[\%\^\&\*\#\@\.\-\+\_\=\/\\♡\$]/g, (t) => (
|
.replace(/[\%\^\&\*\#\@\.\-\+\_\=\/\\♡\$]/g, (t) => (
|
||||||
SymbolMap[t as keyof typeof SymbolMap]
|
SymbolMap[t as keyof typeof SymbolMap]
|
||||||
))
|
))
|
||||||
.replace(/㎡/g, "제곱미터")
|
|
||||||
.replace(/㎢/g, "제곱킬로미터")
|
|
||||||
.replace(/([\?\!]+)/g, (_, content: string) => content[0])
|
.replace(/([\?\!]+)/g, (_, content: string) => content[0])
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue