Skip to content

Commit

Permalink
fix: clean up unused things
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulalaby committed May 17, 2023
1 parent 47fd58a commit 35d471d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
19 changes: 9 additions & 10 deletions src/discord2telegram/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export const escapeHTMLSpecialChars = R.compose(
*
* @returns Filtered string
*/
export function removeCustomEmojis(input: string){
const regex = /\<[^;]*\>\s?/gi;
return input.split(regex).join('');
export function removeCustomEmojis(input: string) {
const regex = /<[^;]*>\s?/gi;
return input.split(regex).join("");
}

/**
Expand All @@ -48,8 +48,8 @@ export function removeCustomEmojis(input: string){
*
* @returns Filtered string
*/
export function replaceCustomEmojis(input: string, replacement: string){
const regex = /\<[^;]*\>/g;
export function replaceCustomEmojis(input: string, replacement: string) {
const regex = /<[^;]*>/g;
return input.replace(regex, replacement);
}

Expand All @@ -61,8 +61,8 @@ export function replaceCustomEmojis(input: string, replacement: string){
*
* @returns Processed string
*/
export function replaceAtWith(input: string, replacement: string ){
const regex = /\@/g;
export function replaceAtWith(input: string, replacement: string) {
const regex = /@/g;
return input.replace(regex, replacement);
}

Expand All @@ -73,8 +73,7 @@ export function replaceAtWith(input: string, replacement: string ){
*
* @returns Processed string
*/
export function replaceExcessiveSpaces(input: string){
export function replaceExcessiveSpaces(input: string) {
const regex = /[^\S\n]{2,}/g;
return input.replace(regex, ' ');
return input.replace(regex, "");
}

16 changes: 3 additions & 13 deletions src/discord2telegram/md2html.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import simpleMarkdown, { SingleASTNode } from "simple-markdown";
import { TelegramSettings } from "../settings/TelegramSettings";
import {
escapeHTMLSpecialChars,
customEmojiFilter,
replaceAtWithHash,
replaceExcessiveSpaces,
removeNewlineSpaces
} from "./helpers";
import { escapeHTMLSpecialChars, removeCustomEmojis, replaceAtWith, replaceExcessiveSpaces } from "./helpers";
import R from "ramda";

/***********
Expand Down Expand Up @@ -130,19 +124,15 @@ export function md2html(text: string, settings: TelegramSettings) {

function htmlCleanup(input: string, settings: TelegramSettings) {
if (settings.useCustomEmojiFilter) {
input = customEmojiFilter(input);
input = removeCustomEmojis(input);
}

if (settings.replaceAtWithHash) {
input = replaceAtWithHash(input);
input = replaceAtWith(input, "#");
}

if (settings.replaceExcessiveSpaces) {
input = replaceExcessiveSpaces(input);
}

if (settings.removeNewlineSpaces) {
input = removeNewlineSpaces(input);
}
return input;
}

0 comments on commit 35d471d

Please sign in to comment.