GitHub Markdown中Mermaid流程图文本加粗失效及箭头标签异常排查
GitHub Mermaid 10.2.0:标签失效及箭头标签半透明问题解决办法
问题原因
- Mermaid 10.x版本调整了HTML标签支持策略,
<b>这类行内HTML标签不再被解析,导致原本的粗体效果失效 - 箭头标签的半透明是Mermaid 10.2.0的默认样式变更
修复方案
直接适配Mermaid 10.2.0的原生语法和样式配置即可:
- 用Mermaid原生的Markdown粗体语法
**内容**替代<b>内容</b> - 通过
linkStyle指令强制设置箭头标签的填充透明度为1,恢复不透明状态
修复后的完整流程图代码
graph TD; A["**CPRD Aurum October 2020 release** with linked Set 21 <br> (April 2021) HES APC, patient IMD, and ONS death data"] --> |"Unique patients with a diabetes-related medcode between 01/01/2004-06/11/2020 and >=1 year data prior and after"| B["**Our extract**: n=1,480,985*"] B -->|"With a diabetes QOF code with a valid date** (quality check to remove those without diabetes)"|C["n=1,138,193"] C --> |"Inconsistencies in diabetes type suggesting <br> coding errors or unclassifiable"|D["n=14"] C --> E["**Diabetes cohort**: n=1,138,179"] E --> F["**01 At-diagnosis cohort**: <br> n=771,678 <br> Index date=diagnosis date"] E --> G["**02 Prevalent cohort**: <br> n=643,143 <br> Actively registered on 01/02/2020 <br> Index date=diagnosis date"] E --> H["**03 Treatment response (MASTERMIND) cohort**: <br> n=995,036 with 3,218,100 unique drug periods <br> For T2D 1st instance dataset excluding drug starts within 91 days <br> of registration: n=769,394 with 1,663,398 unique drug periods <br> With script for diabetes medication <br> Index date=drug start date"] <!-- 设置所有箭头标签为不透明 --> linkStyle 0 fill-opacity:1 linkStyle 1 fill-opacity:1 linkStyle 2 fill-opacity:1 linkStyle 3 fill-opacity:1 linkStyle 4 fill-opacity:1 linkStyle 5 fill-opacity:1 linkStyle 6 fill-opacity:1
补充说明
GitHub平台的Mermaid版本由官方统一维护,用户无法自行切换版本,必须使用当前版本(10.2.0)支持的语法和配置方式实现需求。上述修改完全适配该版本,可还原你期望的粗体效果和不透明箭头标签样式。
内容的提问来源于stack exchange,提问作者KatieY
相关产品推荐
相关产品推荐

