如何在GitHub自述文件中使用Markdown呈现多列?(How to render multiple columns with Markdown in GitHub README?)

编程入门 行业动态 更新时间:2024-10-25 18:23:56
如何在GitHub自述文件中使用Markdown呈现多列?(How to render multiple columns with Markdown in GitHub README?)

为了呈现三列中的项目,我尝试将下面的CSS3指令添加到我的项目的README.md文件中,但是删除了样式:

<div style="-webkit-column-count: 3; -moz-column-count: 3; column-count: 3; -webkit-column-rule: 1px dotted #e0e0e0; -moz-column-rule: 1px dotted #e0e0e0; column-rule: 1px dotted #e0e0e0;"> <div style="display: inline-block;"> <!-- first column's content --> </div> <div style="display: inline-block;"> <!-- second column's content --> </div> <div style="display: inline-block;"> <!-- third column's content --> </div> </div>

这种样式在GitHub处理Markdown之外正确工作。 如何将数据放入Markdown文档的多个列中? 请注意,我不关心IE浏览器的支持,不关心IE是否呈现单列(我的软件项目无法在Windows客户端上运行)。

To render items in three columns, I attempted to add the following CSS3 directives to my project's README.md file, but the styling was stripped out:

<div style="-webkit-column-count: 3; -moz-column-count: 3; column-count: 3; -webkit-column-rule: 1px dotted #e0e0e0; -moz-column-rule: 1px dotted #e0e0e0; column-rule: 1px dotted #e0e0e0;"> <div style="display: inline-block;"> <!-- first column's content --> </div> <div style="display: inline-block;"> <!-- second column's content --> </div> <div style="display: inline-block;"> <!-- third column's content --> </div> </div>

This styling works correctly outside of GitHub's processing of Markdown. How can I put data into multiple columns in a Markdown document? Note that I am not concerned about support for IE browsers and don't care if IE renders a single column (my software project does not work on Windows clients, anyway).

最满意答案

GitHub-Flavored Markdown 仅允许内联HTML中的某些白名单标签和属性 :

HTML

您可以在自述文件,问题和请求中使用HTML的子集。

github / markup的README中可以找到我们支持的标签和属性的完整列表。

关于<div>标签,该自述文件指出除了常规属性白名单之外,只有itemscope和itemtype属性被列入白名单:

abbr , accept , accept-charset , accesskey , action , align , alt , axis , border , cellpadding , cellspacing , char , charoff , charset , checked , cite , clear , cols , colspan , color , compact , coords , datetime , dir , disabled , enctype , for , frame , headers , height , hreflang , hspace , ismap , label , lang , longdesc , maxlength , media , method , multiple , name , nohref , noshade , nowrap , prompt , readonly , rel , rev , rows , rowspan , rules , scope , selected , shape , size , span , start , summary , tabindex , target , title , type , usemap , valign , value , vspace , width , itemprop

没有标签支持style属性。

除非您可以使用该自述文件中列出的标记和属性来破解某些内容,否则我认为您会发现您运气不佳。

另一种方法是将GitHub Pages网站放在一起,这似乎更加灵活。

GitHub-Flavored Markdown only permits certain whitelisted tags and attributes in inline HTML:

HTML

You can use a subset of HTML within your READMEs, issues, and pull requests.

A full list of our supported tags and attributes can be found in the README for github/markup.

Regarding <div> tags, that README says that only the itemscope and itemtype attributes are whitelisted, in addition to the general attribute whitelist:

abbr, accept, accept-charset, accesskey, action, align, alt, axis, border, cellpadding, cellspacing, char, charoff, charset, checked, cite, clear, cols, colspan, color, compact, coords, datetime, dir, disabled, enctype, for, frame, headers, height, hreflang, hspace, ismap, label, lang, longdesc, maxlength, media, method, multiple, name, nohref, noshade, nowrap, prompt, readonly, rel, rev, rows, rowspan, rules, scope, selected, shape, size, span, start, summary, tabindex, target, title, type, usemap, valign, value, vspace, width, itemprop

No tags support the style attribute.

Unless you can hack something together with the tags and attributes listed in that README I think you'll find that you're out of luck.

An alternative would be to put together a GitHub Pages site, which seems to be much more flexible.

更多推荐

本文发布于:2023-08-01 18:41:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1364822.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自述   文件   如何在   GitHub   Markdown

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!