Github Markdown-无法通过内联CSS和类更改任何样式 [英] Github markdown - cannot change any style by inline-css and class

查看:145
本文介绍了Github Markdown-无法通过内联CSS和类更改任何样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试更改字体大小和行高,但失败了.我尝试过内联样式:

I try to change font size and line height but failed. I've tried inline style:

<div style="font-size: 12px; line-height: 12px;")>bla</div>

和班级:

<style>
.footnote {font-size: 12px !important; line-height: 12px !important;}
</style>

<div class="footnote">bla</div>

和markdown语法:

and markdown syntax:

<font size=1>bla</font>

它们都不起作用.在Concole中,DOM就像:

None of them work. In Concole the DOM is just like:

<div>bla</div>

和样式始终默认为markdown定义:

and styles are always defined by default markdown:

.markdown-body {
    font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;
    font-size: 16px;
    line-height: 1.5;
}

似乎我的设置无效,甚至没有添加类.

我还尝试了其他一些标签,例如< p>< span> ,但不起作用.

P.S.在VS Code Github Markdown预览中,它可以正确显示.

Seems my setting takes no effect and even class is not added.

I also tried some other tags like <p> <span> but not working.

P.S. In VS Code Github Markdown preview it shows properly.

推荐答案

出于安全考虑,这是不可能的.

This is not possible due to security concerns.

实际上,它与Markdown无关,而是GitHub对所有用户提供的标记的后处理,如 github/markup .Markdown到HTML的转换发生在步骤1中,这使您的标记和属性保持不变.但是,值得注意的是步骤2:

In fact, it is not related to Markdown, but rather GitHub's post-processing of all user provided markup, as documented in github/markup. The conversion of Markdown to HTML happens in step 1, which leaves your tags and attributes intact. However, of note is step 2:

  1. 对HTML进行了净化处理,积极删除可能危害您和您的亲属的东西,例如 script 标签, inline-styles class id 属性.
  1. 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.

该文档的先前版本链接到代码当时.目前尚不清楚他们是否仍在使用该消毒剂或其他消毒剂.但是,查看该消毒程序的代码可以清楚地看出它们正在剥离所有用户定义的样式.如果他们更新了新的消毒剂,很可能会变得更加严格.

A previous version of that document linked to the code for the HTML sanitizer they were using at the time. Whether they are still using that sanitizer or a different one is currently unknown. However, a review of the code for that sanitizer makes it clear that they are striping out all user defined styles. If they have updated to a new sanitizer, it is likely that it has been made more strict.

最后,很明显,GitHub不允许在其网站上使用任何用户定义的样式.

In conclusion, it is clear that GitHub does not allow any user-defined styles to be used on their site.

这篇关于Github Markdown-无法通过内联CSS和类更改任何样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆