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

Improve Mermaid's Markdown rendering #11670

Closed
3 tasks done
etchnight opened this issue Jun 9, 2024 · 8 comments
Closed
3 tasks done

Improve Mermaid's Markdown rendering #11670

etchnight opened this issue Jun 9, 2024 · 8 comments
Assignees
Milestone

Comments

@etchnight
Copy link

etchnight commented Jun 9, 2024

Mermaid 渲染 Markdown 偏移问题

Is there an existing issue for this?

  • I have searched the existing issues

Can the issue be reproduced with the default theme (daylight/midnight)?

  • I was able to reproduce the issue with the default theme

Could the issue be due to extensions?

  • I've ruled out the possibility that the extension is causing the problem.

Describe the problem

在Mermaid中使用Markdown时,渲染出的Markdown文本会出现偏移,具体来说,是在Mermaid的流程图中,节点使用Markdown文本,如:

flowchart LR
    markdown["`This **is** _Markdown_`"]
    newLines["`Line1     Line 2     Line 3`"]
    markdown --> newLines

渲染结果为:
捕获

Expected result

上例中的渲染结果应该为:
捕获2

Screenshot or screen recording presentation

No response

Version environment

- Version: v3.0.17
- Operating System: windows
- Browser (if used):

Log file

不需要

More information

经查,是由以下CSS规则导致,该规则位于siyuan\app\src\assets\scss\component\_typography.scss文件中(第25行):

.b3-typography p, .b3-typography [data-node-id], .protyle-wysiwyg p, .protyle-wysiwyg [data-node-id] {
    line-height: 1.625;
    padding: 4px;
    margin: 2px 0;
    border-radius: var(--b3-border-radius);
}

原因是在Mermaid中使用Markdown文本时,渲染生成的元素为<p>而非<span>.
目前临时的修复方案是在代码片段中添加如下代码片段:

.protyle-wysiwyg foreignObject p {
  padding: 0;
  margin: 0;
}
Vanessa219 added a commit that referenced this issue Jun 13, 2024
@Vanessa219 Vanessa219 added this to the 3.1.0 milestone Jun 13, 2024
@88250 88250 changed the title Mermaid 渲染 Markdown 偏移问题 Improve Mermaid's Markdown rendering Jun 13, 2024
copialot pushed a commit to copialot/siyuan that referenced this issue Aug 3, 2024
@idealkindom
Copy link

确实有这个问题,请测试下我这个

sequenceDiagram
    autonumber
    participant 1 as $$\alpha$$
    participant 2 as $$\beta$$
    1->>2: Solve: $$\sqrt{2+2}$$
    2-->>1: Answer: $$2$$
    Note right of 2: $$\sqrt{2+2}=\sqrt{4}=2$$
Loading

@Vanessa219
Copy link
Member

还有问题的话,导出 .sy 文件上传一下。

@idealkindom
Copy link

还有问题的话,导出 .sy 文件上传一下。

请查收附件和截图。这个mermaid图里α和β会显示不全。之前zettlr和Joplin也有这种问题,不过Joplin 3.1.1已经修复了。
Mermaid渲染问题.sy.zip
思源mermaid渲染问题截图_2024-08-11_08-34-35

@idealkindom
Copy link

还有问题的话,导出 .sy 文件上传一下。

不过我觉得思源这个最大的硬伤还是导出图片超级慢,并且不支持svg,对于内容多一点的脑图、流程图,png那分辨率根本没法看

@Vanessa219
Copy link
Member

这些可以使用导出 html

@idealkindom
Copy link

idealkindom commented Aug 12, 2024 via email

@idealkindom
Copy link

idealkindom commented Aug 12, 2024 via email

Vanessa219 added a commit that referenced this issue Aug 12, 2024
@Vanessa219
Copy link
Member

还有问题的话,导出 .sy 文件上传一下。

请查收附件和截图。这个mermaid图里α和β会显示不全。之前zettlr和Joplin也有这种问题,不过Joplin 3.1.1已经修复了。 Mermaid渲染问题.sy.zip 思源mermaid渲染问题截图_2024-08-11_08-34-35

下个版本再看看

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants