Which inline html styles does GitHub markdown accept? [closed]

浪子不回头ぞ 提交于 2019-11-30 07:27:17

问题


This gives a pretty thorough description of how HTML elements are interpreted by markdown. But it does not discuss styles.

So far, the only thing I can get to work is image width.

  1. I can't find a list anywhere of what is accepted/rendered
  2. It appears that the style="....." attribute is completely ignored.
  3. I can't even find a list of the old-fashioned style attributes (as opposed to the style attribute style=...)

https://gist.github.com/abalter/46df1b79e9f429342972477d7c20cebc

EDIT
Change span to div due to div being in the whitelisted tags per @waylan's comment under @chris's answer.

EDIT 2
It appears that firefox and chrome don't render any style attributes any more at all.


回答1:


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.

You're right: style tags are not included in the whitelist. They are ignored.

The permitted attributes differ by tag. I recommend referring to the sanitization filter link above. It leads to a fairly readable Ruby source file.



来源:https://stackoverflow.com/questions/44831505/which-inline-html-styles-does-github-markdown-accept

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!