fix: Remove no longer required unescaping, closes #5555
This commit is contained in:
@@ -6,11 +6,6 @@ it("should trim the title", () => {
|
||||
it("should extract first title", () => {
|
||||
expect(parseTitle(`# Title one\n# Title two`).title).toBe("Title one");
|
||||
});
|
||||
it("should remove escape characters", () => {
|
||||
expect(parseTitle(`# Thing \\- one`).title).toBe("Thing - one");
|
||||
expect(parseTitle(`# \\[wip\\] Title`).title).toBe("[wip] Title");
|
||||
expect(parseTitle(`# \\> Title`).title).toBe("> Title");
|
||||
});
|
||||
it("should parse emoji if first character", () => {
|
||||
const parsed = parseTitle(`# 😀 Title`);
|
||||
expect(parsed.title).toBe("😀 Title");
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
import emojiRegex from "emoji-regex";
|
||||
import unescape from "./unescape";
|
||||
|
||||
export default function parseTitle(text = "") {
|
||||
const regex = emojiRegex();
|
||||
|
||||
// find and extract title
|
||||
const firstLine = text.trim().split(/\r?\n/)[0];
|
||||
const trimmedTitle = firstLine.replace(/^#/, "").trim();
|
||||
|
||||
// remove any escape characters
|
||||
const title = unescape(trimmedTitle);
|
||||
const title = firstLine.replace(/^#/, "").trim();
|
||||
|
||||
// find and extract first emoji
|
||||
const matches = regex.exec(title);
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
const unescape = (text: string) =>
|
||||
text.replace(/\\([\\`*{}[\]()#+\-.!_>])/g, "$1").replace(/\n\\\n/g, "\n\n");
|
||||
|
||||
export default unescape;
|
||||
Reference in New Issue
Block a user