gpt4 book ai didi

css - 混合 Github markdown 语言和 CSS

转载 作者:太空宇宙 更新时间:2023-11-04 09:36:49 24 4
gpt4 key购买 nike

如何将 CSS 添加到 github 的 markdown 语言中?

我已经能够通过在 html 标签中使用 style 属性来做到这一点,例如:

<p style="text-align: center;">This is some random text</p>

但是如果我将 css 移到开头,例如:

<style>
p {
text-align: center;
}
</style>

<p>This is some random text</p>

Github 不识别它,只是将 css 代码写入屏幕。

我正在使用 Atom,而 Markdown Preview 包实际上正确地识别了这一点,即使在远程存储库上它显示错误。 Google Chrome 扩展程序 Markdown Preview Plus 也是如此。

有没有办法做到这一点?在 html 标签中编写 css 感觉完全错误。

最佳答案

After GitHub converts Markdown to HTML ,

The HTML is sanitized, aggressively removing things that could harm you and your kin—such as script tags, inline-styles, and class or id attributes. See the sanitization filter for the full whitelist.

style 标签不包含在 GitHub 的白名单中,因此被移除。我真的很惊讶内联 style 属性的工作;它们似乎也没有包含在白名单中,并且在上一段中明确提到。

无论如何,GitHub 不允许在 Markdown 中包含任意 HTML。

关于css - 混合 Github markdown 语言和 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40261461/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com