This commit is contained in:
hackrobot
2024-05-13 16:34:56 +08:00
parent 3bec52d5a5
commit fa5c696c53
3 changed files with 79 additions and 5 deletions

View File

@@ -0,0 +1,3 @@
html,body{
user-select: auto !important;
}

View File

@@ -32,12 +32,64 @@ marked.setOptions({
return val;
},
});
// 符号
// 🔥❓👉
// 0⃣1⃣2⃣3⃣4⃣5⃣6⃣7⃣8⃣9⃣🔟
// ©️⭐🔍〰️➖
const renderer = new marked.Renderer();
// 图片调整300px
renderer.image = function (href, title, text) {
console.log("href, title, text", href, title, text);
return `<img width="300px" src="${href}" alt="${text}"/>
<div class="desc">🥶${text}</div>`;
// <div class="desc">${text}</div>
return `<img width="300px" src="${href}" alt="${text}"/>`;
};
// 有序列表
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 input = body;
const matches = [...input.matchAll(regex)];
const texts = matches.map((match) => match[1]);
console.log(texts); // 输出: ["测试111", "测试222", "if"]
// 0⃣',
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('');
// return `1⃣`
return `${string}`
};
// 无序列表 ▫️
renderer.listitem = function (text, task, checked) {
// return `<li>${text}</li>\n`;
return `▫️ ${text}<br/>`;
};
// 任务列表
renderer.checkbox = function (checked) {
// ✅❌
return !!checked ? "✅" : "❌";
return (
"<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox">'
);
};
// 标题
renderer.heading = function (text, level, raw) {
// ignore IDs
return `📋<span>${text}</span> <br/>`;
// return `<h${level}>${text}</h${level}>\n`;
};
// 分隔符
renderer.hr = function () {
// return '<hr>\n';
return "<br/><br/>";
};
// 引用符号
@@ -50,13 +102,27 @@ renderer.blockquote = function (quote) {
var content = match[1]; // 获取第一个捕获组的内容
console.log(content);
}
return `❣️<span class="blockquote">${content}</span>`;
return `👉<span class="blockquote">${content}</span>`;
};
marked.use({ renderer });
// ![测试图片2](http://hackrobot-1258475618.cos.ap-shenzhen-fsi.myqcloud.com/202304081955211.png)
const markTextStr = marked(
`![测试图片2](http://hackrobot-1258475618.cos.ap-shenzhen-fsi.myqcloud.com/202304081955211.png)
>测试`
`
## 标题
>测试
随便测试普通的文本,要不要来个内敛的字符串
---
- 无序列表1
- 无序列表2
- [ ] 任务列表
- [x] 完成任务
1. 测试111
2. 测试222
3. iefw4t43t43t
`
);
// export default class Index extends Component {
const Index = () => {

View File

@@ -1,5 +1,10 @@
html,body{
user-select: auto
}
.index {
// font-size: 28px;
user-select:auto;
font-size: 16px;
.payBtn{
// font-size: 30px;