This commit is contained in:
hackrobot
2024-05-21 15:21:57 +08:00
parent 6d054b6849
commit f127b316c2

View File

@@ -59,11 +59,11 @@ marked.setOptions({
// ©️⭐🔍〰️➖
// 修改 marked 的解析规则
const block = marked.Lexer.rules.block;
// const block = marked.Lexer.rules.block;
// block.gfm.hr = /^( *[-*_]){3,} *(?:\n+|$)/;
// 自定义水平线规则,确保它们在文档中被正确识别
block.gfm.hr =
/^ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
// block.gfm.hr =
// /^ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
const renderer = new marked.Renderer();
// const originRenderer = _.cloneDeep(renderer);
@@ -226,8 +226,10 @@ renderer.link = function (href, title, text) {
};
renderer.paragraph = function (text) {
return `<p>${text}</p>\n`;
// return `<p>${text}</p>\n`;
// return `<p>${text}</p>`;
return `<div>${text}</div>`;
};
renderer.br = function () {
return '<br>';
@@ -273,8 +275,11 @@ const Index = () => {
const copyToClipboard = () => {
if (divRef.current) {
// const htmlContent = divRef.current.innerHTML;
// const htmlContent = divRef.current.outerHTML;
const htmlContentinnerHTML = divRef.current.innerHTML;
console.log('htmlContentinnerHTML',htmlContentinnerHTML)
const htmlContentouterHTML = divRef.current.outerHTML;
console.log('htmlContentouterHTML',htmlContentouterHTML)
const htmlContent = divRef.current.innerText;
navigator.clipboard