Skip to content

Commit

Permalink
fix: rename html string parser
Browse files Browse the repository at this point in the history
  • Loading branch information
shuta13 committed Jan 1, 2024
1 parent fff9dd2 commit fe23339
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/libs/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const htmlRegExp = /<\/?[^>]+(>|$)/g;
function isStringWithoutHtml(str: string): str is StringWithoutHtml {
return !str.match(htmlRegExp);
}
export function getStringWithoutHtml(str: string) {
export function parseStringWithoutHtml(str: string) {
const parsed = str.replace(htmlRegExp, "");
return isStringWithoutHtml(parsed) ? parsed : ("" as StringWithoutHtml);
}
4 changes: 2 additions & 2 deletions src/libs/presenters/AboutOutput.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Entries } from "~/libs/contentful";
import { getStringWithoutHtml, parseMarkdown } from "~/libs/parser";
import { parseStringWithoutHtml, parseMarkdown } from "~/libs/parser";
import { About } from "~/libs/entities/About";

export class AboutOutput implements About {
Expand All @@ -14,7 +14,7 @@ export class AboutOutput implements About {
history: parseMarkdown(String(fields.history || "")),
og: {
title: String(fields.title || ""),
description: getStringWithoutHtml(
description: parseStringWithoutHtml(
String(fields.summary || "").replace(/\n/g, ""),
),
},
Expand Down
4 changes: 2 additions & 2 deletions src/libs/presenters/GuidelineOutput.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Entries } from "~/libs/contentful";
import { getStringWithoutHtml, parseMarkdown } from "~/libs/parser";
import { parseStringWithoutHtml, parseMarkdown } from "~/libs/parser";
import { Guideline } from "~/libs/entities/Guideline";

export class GuidelineOutput implements Guideline {
Expand Down Expand Up @@ -36,7 +36,7 @@ export class GuidelineOutput implements Guideline {
aboutSponsors: parseMarkdown(String(fields.about_sponsors || "")),
og: {
title: String(fields.title || ""),
description: getStringWithoutHtml(
description: parseStringWithoutHtml(
String(fields.summary || "").replace(/\n/g, ""),
),
},
Expand Down

0 comments on commit fe23339

Please sign in to comment.