问题
So recently i was using Azure DevOps for projects and i really liked the wiki there.
However a week ago for a University project i had to use GitHub directly, where i realized that even basic formatting options are missing. One of the missing option that hit me hard was that i can't even color texts.
In Azure DevOps you can color texts like this:
<font color="red">Please Note that this is a work in progress repository!</font>
After a little bit of searching on the internet i only found half solutions like use a picture etc.., and GitHub issues that were closed without real explanations.
So does anyone know why GitHub does not allow us to color our texts? Is there a technical reason behind this?
回答1:
In general, GitHub doesn't allow most transformations on text in wikis, READMEs, and rendered HTML. There are a couple reasons for this.
One, many transformations can allow overflowing regions of the page or other techniques that could possibly spoof content. This includes many font
tags and many types of CSS. Because spoofing or attempting to modify other page content is a security issue, most of those UI tweaks are disallowed. I suspect, in fact, that GitHub strips font
tags altogether for this reason.
Two, GitHub wants the page to be legible and readable for all users. Rendered pages need to be able to be read on a wide variety of devices, with a wide variety of font sizes, by pretty much every user. Even if you can read light grey on white, many people cannot, and for accessibility reasons, changing colors arbitrarily isn't a good idea. GitHub is required by law to be accessible.
Three, if people can write content in pages that is unreadable, say white on white, then they can create a spam and abuse problem. This means that people can try to host content that links to spammy sites and hide it from view, benefiting from the fact that GitHub is a popular site.
Four, letting people change styling and colors presents potential problems. Even if your styling were unproblematic for all of the other reasons above, if GitHub wanted to introduce a dark mode, then letting people arbitrarily color their wikis would prevent that from being a possibility.
来源:https://stackoverflow.com/questions/60783053/why-github-does-not-allow-to-color-texts-in-md-files