From a68a4540670b2d30502ed58df2ff70e61c7ade30 Mon Sep 17 00:00:00 2001 From: YiSheng Date: Thu, 24 Oct 2024 18:02:01 +0800 Subject: [PATCH] fix: ios < 17 not support look behind --- packages/package.json | 2 +- .../simple-markdown/src/legacyMarkdownAdapter.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/package.json b/packages/package.json index da038c81ab..62393d3da6 100644 --- a/packages/package.json +++ b/packages/package.json @@ -1,6 +1,6 @@ { "name": "@junyiacademy/perseus-core", - "version": "1.0.46", + "version": "1.0.47", "main": "./dist/index.js", "types": "./dist/index.d.ts", "license": "MIT", diff --git a/packages/simple-markdown/src/legacyMarkdownAdapter.ts b/packages/simple-markdown/src/legacyMarkdownAdapter.ts index d197c8e451..6a454cac92 100644 --- a/packages/simple-markdown/src/legacyMarkdownAdapter.ts +++ b/packages/simple-markdown/src/legacyMarkdownAdapter.ts @@ -1,18 +1,18 @@ export const adaptLegacyMarkdown = (str: string) => { // heading 前只有一個 \n 時,將 \n 改為 \n\n const addedNewLineAboveHeadingStr = str.replace( - /(?<=[^\n]\n *)(#{1,6}.*)/g, - "\n$1", + /([^\n]\n *)(#{1,6}.*)/g, + "$1\n$2", ); // heading 後只有一個 \n 時,將 \n 改為 \n\n const addedNewLineUnderHeadingStr = addedNewLineAboveHeadingStr.replace( - /(?<=\n *|^)(#{1,6}[^\n]*)(?=\n[^\n])/g, - "$1\n", + /(\n *|^)(#{1,6}[^\n]*)(?=\n[^\n])/g, + "$1$2\n", ); // hr 後只有一個 \n 時,將 \n 改為 \n\n const addedNewLineUnderHrStr = addedNewLineUnderHeadingStr.replace( - /(?<=\n *)([-*_]{3,})(?=\n[^\n])/g, - "$1\n", + /(\n *)([-*_]{3,})(?=\n[^\n])/g, + "$1$2\n", ); return addedNewLineUnderHrStr;