Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: 语雀文章中的换行在转换成markdown之后丢失 #6

Closed
Jason-Ma-0012 opened this issue Jun 14, 2023 · 2 comments
Closed

Comments

@Jason-Ma-0012
Copy link

要在markdown中完成换行需要在行尾添加2个空格

@LetTTGACO
Copy link
Owner

要在markdown中完成换行需要在行尾添加2个空格

确实有这个问题,这几天会修复。

@LetTTGACO
Copy link
Owner

临时处理办法:

不同博客的md文件渲染逻辑会有细微差别。可以先手动通过自定义文档适配器处理

const {matterMarkdownAdapter} = require('@elog/plugin-adapter')

/**
 * 自定义文档处理器
 * @typedef {Object} DocDetail
 * @param {DocDetail} doc doc的类型定义为 DocDetail
 * @returns {string} 返回处理后的文档内容字符串
 */
const format = (doc) => {
 // 将单个换行替换为2个换行
  doc.body = doc.body.replace(/\n/gi, '\n\n')
 // 生成带有front-matter的文档(可选)
 // 返回字符串即可
  return matterMarkdownAdapter(doc);
};

module.exports = {
  format,
};

@vannvan vannvan mentioned this issue Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants