update
This commit is contained in:
@@ -61,7 +61,6 @@ const createDecoratedTitleHTML = (text: any) => {
|
||||
|
||||
return `<div>${topBorder}<br/>${middleLine}<br/>${bottomBorder}</div>`;
|
||||
// return `<div>${topBorder}<br/>${middleLine}<br/>${bottomBorder}</div><br/>`;
|
||||
|
||||
};
|
||||
|
||||
marked.setOptions({
|
||||
@@ -101,49 +100,61 @@ renderer.image = function (href, title, text) {
|
||||
return `<img width="300px" src="${href}" alt="${text}"/>`;
|
||||
};
|
||||
|
||||
// let listSinbal="▫️ "
|
||||
let listSinbal = '🔸';
|
||||
|
||||
// 有序列表
|
||||
renderer.list = function (body, ordered, start) {
|
||||
// console.log("body,ordered, start", body, ordered, start);
|
||||
const type = ordered ? 'ol' : 'ul';
|
||||
// console.log("type===>", type);
|
||||
const startatt = ordered && start !== 1 ? ' start="' + start + '"' : '';
|
||||
// 正则取值
|
||||
// const regex = /▫️\s*(.*?)<br\/?>/g;
|
||||
const regex = /([^<]*)<br\/?>/g;
|
||||
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(listSinbal));
|
||||
// 0️⃣',
|
||||
const numbers = ['1️⃣', '2️⃣', '3️⃣', '4️⃣', '5️⃣', '6️⃣', '7️⃣', '8️⃣', '9️⃣', '🔟'];
|
||||
|
||||
|
||||
// 移除 `<div>` 和 `</div>` 标签
|
||||
const cleanedBody = body.replace(/<\/?div>/g, '');
|
||||
|
||||
// 正则表达式匹配每个以 <br/> 结尾的列表项
|
||||
const regex = /([^<]*)<br\/?>/g;
|
||||
const input = cleanedBody;
|
||||
|
||||
// 正则取值
|
||||
// // const regex = /▫️\s*(.*?)<br\/?>/g;
|
||||
// const regex = /([^<]*)<br\/?>/g;
|
||||
// const input = body;
|
||||
// console.log('input--', input);
|
||||
|
||||
const matches = [...input.matchAll(regex)];
|
||||
console.log('matches--', matches);
|
||||
const texts = matches.map((match) => match[1]);
|
||||
console.log('texts===>', texts); // 输出: ["测试111", "测试222", "if"]
|
||||
const newArray = texts.filter((item) => item.includes(listSinbal));
|
||||
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 ? '<br/><span>111</sapn>' : ""}
|
||||
return value.indexOf(listSinbal) !== -1
|
||||
? `<div>${
|
||||
type === 'ol' ? numbers[newArray.indexOf(value)] : listSinbal
|
||||
}${value.replace(listSinbal, '')} </div>`
|
||||
: `<div style="white-space:pre;">\t${value}</div>`;
|
||||
: // : `<div style="white-space:pre;">\t${value}</div>`;
|
||||
`<div style="white-space:pre;">         ┊ ${value}</div>`;
|
||||
})
|
||||
.join('');
|
||||
// return `1️⃣`
|
||||
// console.log("string===>", string);
|
||||
|
||||
return `${string}`;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// 示例输入
|
||||
const input = `🔸11<br/>🔸22<br/><br/>🔸33`;
|
||||
console.log(renderer.list(input, false, 1));
|
||||
|
||||
// 无序列表 ▫️
|
||||
renderer.listitem = function (text, task, checked) {
|
||||
// return `<li>${text}</li>\n`;
|
||||
return `${listSinbal}${text}<br/>`;
|
||||
return `${listSinbal}${text}\n`;
|
||||
|
||||
// return `${listSinbal}${text}\n`;
|
||||
|
||||
// return `➖${text}<br/>`;
|
||||
};
|
||||
|
||||
@@ -336,7 +347,7 @@ const Index = () => {
|
||||
// │ 🆔 hackrobot
|
||||
// ╰────────────────╯<br>💬 随时欢迎聊天`;
|
||||
|
||||
let contactMe = `➖➖➖➖➖\n💬 后台发送关键词: 加群`;
|
||||
let contactMe = `<br>➖➖➖➖➖<br>💬 欢迎交流<br>后台私信发送『关键词』: 加群`;
|
||||
// setmarkText(value);
|
||||
setmarkText(value + contactMe);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user