From 45027cc520992b5d68acf246f0fa9e3e9412c0f0 Mon Sep 17 00:00:00 2001 From: hackrobot Date: Mon, 13 May 2024 18:07:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E7=BB=84=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/index/index.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pages/index/index.jsx b/src/pages/index/index.jsx index 8589040..b8a364d 100644 --- a/src/pages/index/index.jsx +++ b/src/pages/index/index.jsx @@ -57,18 +57,22 @@ renderer.list = function (body, ordered, start) { const input = body; const matches = [...input.matchAll(regex)]; const texts = matches.map((match) => match[1]); + // 不含▫️的元素数量 + // const diffcCount=texts.length-texts.filter(item => item.includes('▫️')).length; console.log("texts===>", texts); // 输出: ["测试111", "测试222", "if"] + const newArray = texts.filter(item => item.includes('▫️')); // 0️⃣', const numbers = ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣", "🔟"]; const string = texts .map((value, index) => { console.log("value, index==>", value, index); // ${ value.indexOf("▫️ ") === -1 ? '
111' : ""} - return value.indexOf("▫️ ") !== -1 ?`
${type === "ol" ? numbers[index] : "▫️ "}${value.replace('▫️ ','')}
`:`
\t${value}
`; + return value.indexOf("▫️ ") !== -1 ?`
${type === "ol" ? numbers[newArray.indexOf(value)] : "▫️ "}${value.replace('▫️ ','')}
`:`
\t${value}
`; }) .join(""); // return `1️⃣` console.log("string===>", string); + return `${string}`; }; @@ -137,6 +141,9 @@ const markTextStr = marked( 恶魔女哪里的请 2. 你好啊 3. iefw4t43t43t + 永远不要相信一个 + --- + 相信我 ` ); // export default class Index extends Component {