Skip to content

Commit

Permalink
replace out-of-character lib because it will cause build error
Browse files Browse the repository at this point in the history
  • Loading branch information
sywhb committed Jun 19, 2023
1 parent 22046e3 commit 4f7e370
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 49 deletions.
60 changes: 15 additions & 45 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"luxon": "^3.1.1",
"markdown-escape": "^2.0.0",
"mustache": "^4.2.0",
"out-of-character": "^1.2.1",
"process": "^0.11.10"
},
"volta": {
Expand Down
11 changes: 8 additions & 3 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { diff_match_patch } from "diff-match-patch";
import { DateTime } from "luxon";
import escape from "markdown-escape";
import { parseYaml } from "obsidian";
import { replace } from "out-of-character";
import { Highlight } from "./api";

export const DATE_FORMAT_W_OUT_SECONDS = "yyyy-MM-dd'T'HH:mm";
Expand Down Expand Up @@ -92,8 +91,9 @@ export const unicodeSlug = (str: string, savedAt: string) => {
};

export const replaceIllegalChars = (str: string): string => {
// remove invisible characters
return replace(str.replace(ILLEGAL_CHAR_REGEX, REPLACEMENT_CHAR));
return removeInvisibleChars(
str.replace(ILLEGAL_CHAR_REGEX, REPLACEMENT_CHAR)
);
};

export function formatDate(date: string, format: string): string {
Expand Down Expand Up @@ -167,3 +167,8 @@ export const removeFrontMatterFromContent = (content: string): string => {

export const snakeToCamelCase = (str: string) =>
str.replace(/(_[a-z])/g, (group) => group.toUpperCase().replace("_", ""));

const removeInvisibleChars = (str: string): string => {
// eslint-disable-next-line no-control-regex
return str.replace(/[^\u0000-\u007E]/g, "");
};

0 comments on commit 4f7e370

Please sign in to comment.