Skip to content

Commit fc6e6f3

Browse files
committed
feat: better markdown'
1 parent 6908231 commit fc6e6f3

File tree

5 files changed

+29
-30
lines changed

5 files changed

+29
-30
lines changed

apps/frontend/src/components/new-launch/heading.component.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ export const HeadingComponent: FC<{
77
currentValue: string;
88
}> = ({ editor }) => {
99
const setHeading = (level: number) => () => {
10-
editor?.commands?.toggleHeading({ level })
10+
editor?.commands?.unsetUnderline();
11+
editor?.commands?.unsetBold();
12+
editor?.commands?.toggleHeading({ level });
1113
};
1214

1315
return (

libraries/helpers/src/utils/strip.html.validation.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import striptags from 'striptags';
2-
import TurndownService from 'turndown';
3-
const turndownService = new TurndownService();
42

53
const bold = {
64
a: '𝗮',
@@ -137,7 +135,7 @@ export const stripHtmlValidation = (
137135
value: string,
138136
replaceBold = false,
139137
none = false,
140-
convertMentionFunction?: (idOrHandle: string, name: string) => string,
138+
convertMentionFunction?: (idOrHandle: string, name: string) => string
141139
): string => {
142140
if (type === 'html') {
143141
return striptags(value, [
@@ -154,7 +152,30 @@ export const stripHtmlValidation = (
154152
}
155153

156154
if (type === 'markdown') {
157-
return turndownService.turndown(value);
155+
return striptags(
156+
value
157+
.replace(/<h1>([.\s\S]*?)<\/h1>/g, (match, p1) => {
158+
return `<h1># ${p1}</h1>\n`;
159+
})
160+
.replace(/<h2>([.\s\S]*?)<\/h2>/g, (match, p1) => {
161+
return `<h2>## ${p1}</h2>\n`;
162+
})
163+
.replace(/<h3>([.\s\S]*?)<\/h3>/g, (match, p1) => {
164+
return `<h3>### ${p1}</h3>\n`;
165+
})
166+
.replace(/<u>([.\s\S]*?)<\/u>/g, (match, p1) => {
167+
return `<u>__${p1}__</u>`;
168+
})
169+
.replace(/<strong>([.\s\S]*?)<\/strong>/g, (match, p1) => {
170+
return `<strong>**${p1}**</strong>`;
171+
})
172+
.replace(/<li.*?>([.\s\S]*?)<\/li.*?>/gm, (match, p1) => {
173+
return `<li>- ${p1.replace(/\n/gm, '')}</li>`;
174+
})
175+
.replace(/<p>([.\s\S]*?)<\/p>/g, (match, p1) => {
176+
return `<p>${p1}</p>\n`;
177+
})
178+
);
158179
}
159180

160181
if (value.indexOf('<p>') === -1 && !none) {

libraries/nestjs-libraries/src/integrations/social/discord.provider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ export class DiscordProvider extends SocialAbstract implements SocialProvider {
131131
postDetails: PostDetails[]
132132
): Promise<PostResponse[]> {
133133
let channel = postDetails[0].settings.channel;
134+
console.log(postDetails[0].message);
134135
if (postDetails.length > 1) {
135136
const { id: threadId } = await (
136137
await fetch(

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@
109109
"@types/sha256": "^0.2.2",
110110
"@types/stripe": "^8.0.417",
111111
"@types/striptags": "^0.0.5",
112-
"@types/turndown": "^5.0.5",
113112
"@types/yup": "^0.32.0",
114113
"@uidotdev/usehooks": "^2.4.1",
115114
"@uiw/react-md-editor": "^4.0.3",
@@ -213,7 +212,6 @@
213212
"tldts": "^6.1.47",
214213
"transloadit": "^3.0.2",
215214
"tslib": "^2.3.0",
216-
"turndown": "^7.2.0",
217215
"tweetnacl": "^1.0.3",
218216
"twitter-api-v2": "^1.24.0",
219217
"twitter-text": "^3.1.0",

pnpm-lock.yaml

Lines changed: 0 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)