shd101wyy / vscode-markdown-preview-enhanced

One of the "BEST" markdown preview extensions for Visual Studio Code
https://shd101wyy.github.io/markdown-preview-enhanced
Other
1.45k stars 173 forks source link

[BUG] 用<center>修饰表格不生效 #1873

Open ioshift opened 10 months ago

ioshift commented 10 months ago

Describe the bug 在表格两段加上<center></center>后,Preview中没有产生居中效果

Environment

Screenshots image

zyf722 commented 8 months ago

使用 扩展 Markdown Parser 并配合自定义 CSS 可以实现表格居中:

.center {
    display: flex;
    justify-content: center;
    align-items: center;
}
onDidParseMarkdown: async function(html) {
    const modifiedHtml = html.replace(/<table>/g, '<div class="center"><table>');
    return modifiedHtml.replace(/<\/table>/g, '</table></div>');
},

理论上来说不添加 CSS 而是使用 <center> 标签应该同样有效,但考虑到 该标签已被弃用,不建议直接使用该标签。

P.S. 侧边预览中可能无法正常显示,但导出的 HTML 是正确的。