update
This commit is contained in:
@@ -49,19 +49,27 @@ renderer.image = function (href, title, text) {
|
|||||||
renderer.list = function (body, ordered, start) {
|
renderer.list = function (body, ordered, start) {
|
||||||
console.log("body,ordered, start", body, ordered, start);
|
console.log("body,ordered, start", body, ordered, start);
|
||||||
const type = ordered ? "ol" : "ul";
|
const type = ordered ? "ol" : "ul";
|
||||||
console.log("type===>",type)
|
console.log("type===>", type);
|
||||||
const startatt = ordered && start !== 1 ? ' start="' + start + '"' : "";
|
const startatt = ordered && start !== 1 ? ' start="' + start + '"' : "";
|
||||||
// 正则取值
|
// 正则取值
|
||||||
const regex = /▫️\s*(.*?)<br\/?>/g;
|
// const regex = /▫️\s*(.*?)<br\/?>/g;
|
||||||
|
const regex = /([^<]*)<br\/?>/g;
|
||||||
const input = body;
|
const input = body;
|
||||||
const matches = [...input.matchAll(regex)];
|
const matches = [...input.matchAll(regex)];
|
||||||
const texts = matches.map((match) => match[1]);
|
const texts = matches.map((match) => match[1]);
|
||||||
console.log(texts); // 输出: ["测试111", "测试222", "if"]
|
console.log("texts===>", texts); // 输出: ["测试111", "测试222", "if"]
|
||||||
// 0️⃣',
|
// 0️⃣',
|
||||||
const numbers = [ '1️⃣', '2️⃣', '3️⃣', '4️⃣', '5️⃣', '6️⃣', '7️⃣', '8️⃣', '9️⃣', '🔟'];
|
const numbers = ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣", "🔟"];
|
||||||
const string= texts.map((value,index) => `<div>${type==='ol'?numbers[index]:'▫️ '}${value}</div>`).join('');
|
const string = texts
|
||||||
|
.map((value, index) => {
|
||||||
|
console.log("value, index==>", value, index);
|
||||||
|
// ${ value.indexOf("▫️ ") === -1 ? '<br/><span>111</sapn>' : ""}
|
||||||
|
return value.indexOf("▫️ ") !== -1 ?`<div>${type === "ol" ? numbers[index] : "▫️ "}${value.replace('▫️ ','')} </div>`:`<div style="white-space:pre;">\t${value}</div>`;
|
||||||
|
})
|
||||||
|
.join("");
|
||||||
// return `1️⃣`
|
// return `1️⃣`
|
||||||
return `${string}`
|
console.log("string===>", string);
|
||||||
|
return `${string}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 无序列表 ▫️
|
// 无序列表 ▫️
|
||||||
@@ -92,6 +100,11 @@ renderer.hr = function () {
|
|||||||
return "<br/>➖➖➖➖➖<br/>";
|
return "<br/>➖➖➖➖➖<br/>";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 内联样式,使用直角引号「」
|
||||||
|
renderer.codespan = function (text) {
|
||||||
|
return `「${text}」`;
|
||||||
|
};
|
||||||
|
|
||||||
// 引用符号
|
// 引用符号
|
||||||
renderer.blockquote = function (quote) {
|
renderer.blockquote = function (quote) {
|
||||||
console.log("quote", quote);
|
console.log("quote", quote);
|
||||||
@@ -102,7 +115,8 @@ renderer.blockquote = function (quote) {
|
|||||||
var content = match[1]; // 获取第一个捕获组的内容
|
var content = match[1]; // 获取第一个捕获组的内容
|
||||||
console.log(content);
|
console.log(content);
|
||||||
}
|
}
|
||||||
return `👉<span class="blockquote">${content}</span>`;
|
// <pre></pre>
|
||||||
|
return `<span style="white-space:pre;" class="blockquote">\t👉${content}</span> `;
|
||||||
};
|
};
|
||||||
|
|
||||||
marked.use({ renderer });
|
marked.use({ renderer });
|
||||||
@@ -111,17 +125,18 @@ marked.use({ renderer });
|
|||||||
const markTextStr = marked(
|
const markTextStr = marked(
|
||||||
`
|
`
|
||||||
## 标题
|
## 标题
|
||||||
>测试
|
> 测试引用桔子的样子
|
||||||
随便测试普通的文本,要不要来个内敛的字符串
|
随便测试普通的文本,要不要来个\`内敛\`的字符串
|
||||||
---
|
---
|
||||||
- 无序列表1
|
- 无序列表1
|
||||||
|
个人有看看
|
||||||
- 无序列表2
|
- 无序列表2
|
||||||
- [ ] 任务列表
|
- [ ] 任务列表
|
||||||
- [x] 完成任务
|
- [x] 完成任务
|
||||||
1. 测试111
|
1. 测试111
|
||||||
2. 测试222
|
恶魔女哪里的请
|
||||||
|
2. 你好啊
|
||||||
3. iefw4t43t43t
|
3. iefw4t43t43t
|
||||||
|
|
||||||
`
|
`
|
||||||
);
|
);
|
||||||
// export default class Index extends Component {
|
// export default class Index extends Component {
|
||||||
|
|||||||
Reference in New Issue
Block a user