mirror of
https://github.com/outline/outline.git
synced 2025-12-30 07:19:52 -06:00
fix: Remove no longer required unescaping, closes #5555
This commit is contained in:
@@ -13,7 +13,6 @@ import {
|
||||
getCurrentTimeAsString,
|
||||
unicodeCLDRtoBCP47,
|
||||
} from "@shared/utils/date";
|
||||
import unescape from "@shared/utils/unescape";
|
||||
import { parser, schema } from "@server/editor";
|
||||
import { trace } from "@server/logging/tracing";
|
||||
import type Document from "@server/models/Document";
|
||||
@@ -83,7 +82,7 @@ export default class DocumentHelper {
|
||||
* @returns The document title and content as a Markdown string
|
||||
*/
|
||||
static toMarkdown(document: Document | Revision) {
|
||||
const text = unescape(document.text);
|
||||
const text = document.text.replace(/\n\\\n/g, "\n\n");
|
||||
|
||||
if (document.version) {
|
||||
return `# ${document.title}\n\n${text}`;
|
||||
|
||||
@@ -4,7 +4,6 @@ import { find, map } from "lodash";
|
||||
import queryParser from "pg-tsquery";
|
||||
import { Op, QueryTypes, WhereOptions } from "sequelize";
|
||||
import { DateFilter } from "@shared/types";
|
||||
import unescape from "@shared/utils/unescape";
|
||||
import { sequelize } from "@server/database/sequelize";
|
||||
import Collection from "@server/models/Collection";
|
||||
import Document from "@server/models/Document";
|
||||
@@ -410,7 +409,7 @@ export default class SearchHelper {
|
||||
return {
|
||||
results: map(results, (result) => ({
|
||||
ranking: result.searchRanking,
|
||||
context: removeMarkdown(unescape(result.searchContext), {
|
||||
context: removeMarkdown(result.searchContext, {
|
||||
stripHTML: false,
|
||||
}),
|
||||
document: find(documents, {
|
||||
|
||||
@@ -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