more link support
This commit is contained in:
parent
b266595c4b
commit
cca2769b07
1 changed files with 57 additions and 13 deletions
|
|
@ -4,14 +4,20 @@ import IntegerKorean from "./integerKorean.js";
|
||||||
import PhoneNumberKorean from "./phoneNumberKorean.js";
|
import PhoneNumberKorean from "./phoneNumberKorean.js";
|
||||||
import EmojiDescriptions from "./emoji-descriptions.json" with { type: "json" };
|
import EmojiDescriptions from "./emoji-descriptions.json" with { type: "json" };
|
||||||
|
|
||||||
// Process tailing dots
|
// Process trim tailing dots
|
||||||
export function processDots(input: string): string {
|
export function processUnsounds(input: string): string {
|
||||||
return input
|
return (
|
||||||
|
input
|
||||||
|
// Change tailing dots
|
||||||
.replace(/[.,]+$/, "")
|
.replace(/[.,]+$/, "")
|
||||||
.replace(/[.,]{2,}/g, "")
|
.replace(/[.,]{2,}/g, "")
|
||||||
.replace(/[.,]\s/g, " ");
|
.replace(/[.,]\s/g, " ")
|
||||||
|
.replace(/[(){}[]]/g, " ")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 핵토파스칼, 바, 핵타르 AU (에이커 인치 피트 야드)
|
||||||
|
|
||||||
// Process korean letter, choseong shortens
|
// Process korean letter, choseong shortens
|
||||||
export function processKorean(input: string): string {
|
export function processKorean(input: string): string {
|
||||||
input = input.replace(/[아ㅏ]{3,}/g, "아아아");
|
input = input.replace(/[아ㅏ]{3,}/g, "아아아");
|
||||||
|
|
@ -51,6 +57,8 @@ export function processKorean(input: string): string {
|
||||||
}
|
}
|
||||||
export namespace processKorean {
|
export namespace processKorean {
|
||||||
export const DoubleMixedChoseongMap = {
|
export const DoubleMixedChoseongMap = {
|
||||||
|
ㅇㅈㄹ: "이지랄",
|
||||||
|
ㅈㄹㄴ: "지랄노",
|
||||||
ㅎㅇ: "하이",
|
ㅎㅇ: "하이",
|
||||||
ㅅㄹ: "싫어",
|
ㅅㄹ: "싫어",
|
||||||
ㄱㄷ: "기달",
|
ㄱㄷ: "기달",
|
||||||
|
|
@ -74,6 +82,9 @@ export namespace processKorean {
|
||||||
ㅇㅋ: "오키",
|
ㅇㅋ: "오키",
|
||||||
ㅊㅋ: "추카",
|
ㅊㅋ: "추카",
|
||||||
ㄲㅈ: "꺼져",
|
ㄲㅈ: "꺼져",
|
||||||
|
ㅈㅁ: "잠깐만",
|
||||||
|
ㅈㄴ: "존나",
|
||||||
|
ㄱㄴ: "가능",
|
||||||
};
|
};
|
||||||
export const DoubleMixedChoseongMapRegex = new RegExp(
|
export const DoubleMixedChoseongMapRegex = new RegExp(
|
||||||
Object.keys(DoubleMixedChoseongMap)
|
Object.keys(DoubleMixedChoseongMap)
|
||||||
|
|
@ -89,7 +100,7 @@ export namespace processKorean {
|
||||||
ㅇ: "응응",
|
ㅇ: "응응",
|
||||||
ㅊ: "추추",
|
ㅊ: "추추",
|
||||||
ㅠ: "유유",
|
ㅠ: "유유",
|
||||||
ㅜ: "우우",
|
ㅑ: "야야",
|
||||||
ㅋ: (content: string) => "크".repeat(content.length),
|
ㅋ: (content: string) => "크".repeat(content.length),
|
||||||
ㅎ: (content: string) => "흐".repeat(content.length),
|
ㅎ: (content: string) => "흐".repeat(content.length),
|
||||||
ㄱ: (content: string) => {
|
ㄱ: (content: string) => {
|
||||||
|
|
@ -169,7 +180,7 @@ export function processNumber(input: string): string {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.replace(
|
.replace(
|
||||||
/([\d.,]+)\s*([개살시평명])/g,
|
/([\d.,]+)\s*([개살시평명자벌장달병잔번채])/g,
|
||||||
(_, num: string, postfix: string) => {
|
(_, num: string, postfix: string) => {
|
||||||
// 10명 => 열명
|
// 10명 => 열명
|
||||||
if (num.includes(".")) {
|
if (num.includes(".")) {
|
||||||
|
|
@ -273,7 +284,7 @@ export namespace processEmoji {
|
||||||
"↗": "오른쪽 위 화살표",
|
"↗": "오른쪽 위 화살표",
|
||||||
"↘": "오른쪽 아래 화살표",
|
"↘": "오른쪽 아래 화살표",
|
||||||
"↙": "왼쪽 아래 화살표",
|
"↙": "왼쪽 아래 화살표",
|
||||||
"™": "티앰",
|
"™": "트레이드마크",
|
||||||
};
|
};
|
||||||
export const UnicodeSymbolsRegex = new RegExp(
|
export const UnicodeSymbolsRegex = new RegExp(
|
||||||
"[" + Object.keys(UnicodeSymbols).join() + "]",
|
"[" + Object.keys(UnicodeSymbols).join() + "]",
|
||||||
|
|
@ -306,10 +317,42 @@ export function processMarkdown(input: string): string {
|
||||||
] as string | undefined;
|
] as string | undefined;
|
||||||
if (mapped) return mapped;
|
if (mapped) return mapped;
|
||||||
|
|
||||||
if (url.startsWith("tenor.com/view")) {
|
if (
|
||||||
return "움짤!";
|
url.startsWith("tenor.com/view") ||
|
||||||
|
url.startsWith("images-ext-1.discordapp.net/external/")
|
||||||
|
) {
|
||||||
|
return "움짤! ";
|
||||||
}
|
}
|
||||||
return "링크";
|
if (
|
||||||
|
url.startsWith("www.youtube.com/") ||
|
||||||
|
url.startsWith("youtube.com/") ||
|
||||||
|
url.startsWith("youtu.be/")
|
||||||
|
) {
|
||||||
|
return "유튜브 영상! ";
|
||||||
|
}
|
||||||
|
if (url.startsWith("www.reddit.com/") || url.startsWith("reddit.com/")) {
|
||||||
|
return "레딧 링크! ";
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
url.startsWith("www.instagram.com/") ||
|
||||||
|
url.startsWith("instagram.com/")
|
||||||
|
) {
|
||||||
|
return "인스타 링크! ";
|
||||||
|
}
|
||||||
|
if (url.startsWith("x.com/")) {
|
||||||
|
return "엑스 링크! ";
|
||||||
|
}
|
||||||
|
if (url.startsWith("github.com/")) {
|
||||||
|
return "깃허브 링크! ";
|
||||||
|
}
|
||||||
|
if (url.startsWith("store.steampowered.com")) {
|
||||||
|
return "스팀 스토어 링크! ";
|
||||||
|
}
|
||||||
|
if (url.startsWith("steamcommunity.com")) {
|
||||||
|
return "스팀 커뮤니티 링크! ";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "링크 ";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
export namespace processMarkdown {
|
export namespace processMarkdown {
|
||||||
|
|
@ -478,12 +521,13 @@ export namespace processIsolatedSymbol {
|
||||||
|
|
||||||
export function saferKorean(input: string): string {
|
export function saferKorean(input: string): string {
|
||||||
return (input.normalize() + " ")
|
return (input.normalize() + " ")
|
||||||
.let((i) => processDots(i))
|
.let((i) => processUnsounds(i))
|
||||||
.let((i) => processIsolatedSymbol(i))
|
.let((i) => processIsolatedSymbol(i))
|
||||||
.let((i) => processMarkdown(i))
|
.let((i) => processMarkdown(i))
|
||||||
.let((i) => processKorean(i))
|
.let((i) => processKorean(i))
|
||||||
.let((i) => processNumber(i))
|
.let((i) => processNumber(i))
|
||||||
.let((i) => processSymbol(i))
|
.let((i) => processSymbol(i))
|
||||||
.let((i) => processEmoji(i))
|
.let((i) => processEmoji(i))
|
||||||
|
.replace(/\s+/g, " ")
|
||||||
.trim();
|
.trim();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue