如何在 Github 中显示 README.md 文件中的 Table?
How to display Table in README.md file in Github?
我想在 readme.md 文件中显示一个 table。我读了 GitHub Flavored Markdown 并按照它说的做了。所以这是我的 table:
| Attempt | #1 | #2 | #3 | #4 | #5 | #6 | #7 | #8 | #9 | #10 | #11 | #12 |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| Seconds | 301 | 283 | 290 | 286 | 289 | 285 | 287 | 287 | 272 | 276 | 269 | 254 |
但是,我没有看到任何 table,结果如下:
将您的自述文件保存为 README.md 而不是 READ.ME
您需要再次查看文档。你可以看到这个cheatsheet
在您的情况下,您需要制作第二行,如下例所示:
Attempt | #1 | #2 | #3 | #4 | #5 | #6 | #7 | #8 | #9 | #10 | #11
--- | --- | --- | --- |--- |--- |--- |--- |--- |--- |--- |---
Seconds | 301 | 283 | 290 | 286 | 289 | 285 | 287 | 287 | 272 | 276 | 269
此代码与您在 repo 中的代码之间的区别在于带有分隔符的第二行与 header 具有相同的列。之后 table 将显示
| Attempt | #1 | #2 | #3 | #4 | #5 | #6 | #7 | #8 | #9 | #10 | #11 | #12 |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| Seconds | 301 | 283 | 290 | 286 | 289 | 285 | 287 | 287 | 272 | 276 | 269 | 254 |
缩短您的示例以便于理解。
| Attempt | #1 | #2 |
| :---: | :---: | :---: |
| Seconds | 301 | 283 |
并进行了格式化以使其更易于阅读。
| Attempt | #1 | #2 |
| :---: | :-: | :-: |
| Seconds | 301 | 283 |
Headers 必须由竖线 |
字符分隔并由 -
破折号字符加下划线。
You can create tables by assembling a list of words and dividing them with hyphens -
(for the first row), and then separating each column with a pipe |
.
First Header | Second Header
------------- | -------------
Content Cell | Content Cell
Content Cell | Content Cell
For aesthetic purposes, you can also add extra pipes on the ends:
| First Header | Second Header |
| ------------- | ------------- |
| Content Cell | Content Cell |
| Content Cell | Content Cell |
我们的例子变成:
| Attempt | #1 | #2 |
| ------- | --- | --- |
| Seconds | 301 | 283 |
Finally, by including colons : within the header row, you can define text to be left-aligned, right-aligned, or center-aligned:
| Left-Aligned | Center Aligned | Right Aligned |
| :------------ |:---------------:| -----:|
| col 3 is | some wordy text | 00 |
| col 2 is | centered | |
| zebra stripes | are neat | |
所以为了居中对齐,我们的例子变成:
| Attempt | #1 | #2 |
| :-----: | :-: | :-: |
| Seconds | 301 | 283 |
我使用 Markdown Table 工具 (https://www.tablesgenerator.com/markdown_tables) 帮助我从 csv 导入数据或将我的 html tables 转换成 Markdown,我可以简单地将它复制到我的 README.md 文件中,这对我来说真的很省时。
我通常会在 excel 文件的 README 文件中写下我要发布的内容,并将其另存为 csv 并导入此工具并复制粘贴生成的 Markdown,它会创建一个 table 其他人阅读您的说明是体面的。
希望对您有所帮助。
不要忘记在 table 之前包含一个空行,否则格式不正确。
我想在 readme.md 文件中显示一个 table。我读了 GitHub Flavored Markdown 并按照它说的做了。所以这是我的 table:
| Attempt | #1 | #2 | #3 | #4 | #5 | #6 | #7 | #8 | #9 | #10 | #11 | #12 |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| Seconds | 301 | 283 | 290 | 286 | 289 | 285 | 287 | 287 | 272 | 276 | 269 | 254 |
但是,我没有看到任何 table,结果如下:
将您的自述文件保存为 README.md 而不是 READ.ME
您需要再次查看文档。你可以看到这个cheatsheet
在您的情况下,您需要制作第二行,如下例所示:
Attempt | #1 | #2 | #3 | #4 | #5 | #6 | #7 | #8 | #9 | #10 | #11
--- | --- | --- | --- |--- |--- |--- |--- |--- |--- |--- |---
Seconds | 301 | 283 | 290 | 286 | 289 | 285 | 287 | 287 | 272 | 276 | 269
此代码与您在 repo 中的代码之间的区别在于带有分隔符的第二行与 header 具有相同的列。之后 table 将显示
| Attempt | #1 | #2 | #3 | #4 | #5 | #6 | #7 | #8 | #9 | #10 | #11 | #12 |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| Seconds | 301 | 283 | 290 | 286 | 289 | 285 | 287 | 287 | 272 | 276 | 269 | 254 |
缩短您的示例以便于理解。
| Attempt | #1 | #2 |
| :---: | :---: | :---: |
| Seconds | 301 | 283 |
并进行了格式化以使其更易于阅读。
| Attempt | #1 | #2 |
| :---: | :-: | :-: |
| Seconds | 301 | 283 |
Headers 必须由竖线 |
字符分隔并由 -
破折号字符加下划线。
You can create tables by assembling a list of words and dividing them with hyphens
-
(for the first row), and then separating each column with a pipe|
.First Header | Second Header ------------- | ------------- Content Cell | Content Cell Content Cell | Content Cell
For aesthetic purposes, you can also add extra pipes on the ends:
| First Header | Second Header | | ------------- | ------------- | | Content Cell | Content Cell | | Content Cell | Content Cell |
我们的例子变成:
| Attempt | #1 | #2 |
| ------- | --- | --- |
| Seconds | 301 | 283 |
Finally, by including colons : within the header row, you can define text to be left-aligned, right-aligned, or center-aligned:
| Left-Aligned | Center Aligned | Right Aligned | | :------------ |:---------------:| -----:| | col 3 is | some wordy text | 00 | | col 2 is | centered | | | zebra stripes | are neat | |
所以为了居中对齐,我们的例子变成:
| Attempt | #1 | #2 |
| :-----: | :-: | :-: |
| Seconds | 301 | 283 |
我使用 Markdown Table 工具 (https://www.tablesgenerator.com/markdown_tables) 帮助我从 csv 导入数据或将我的 html tables 转换成 Markdown,我可以简单地将它复制到我的 README.md 文件中,这对我来说真的很省时。
我通常会在 excel 文件的 README 文件中写下我要发布的内容,并将其另存为 csv 并导入此工具并复制粘贴生成的 Markdown,它会创建一个 table 其他人阅读您的说明是体面的。
希望对您有所帮助。
不要忘记在 table 之前包含一个空行,否则格式不正确。