How to create a only one row table using markdown
Asked Answered
B

2

10

I use gitbook legacy editor to create a single row table

It looks fine on visual editor but looks really weird when it is on the server.

On visual editor, it is just a one-row table. On the server, it is a one-row table + an empty table body cell which looks ugly. The one-row table now becomes the table header in html.

How can I write a one-row table in markdown just like

[window| Linux| Mac]

Here is the markdown code for one-row table auto-generated by gitbook visual editor

| [Windows](https://xxxx) | [Linux x32](https://xxxx) | [Linux x64](https://xxxx) | [Mac x64](https://xxxxx) |
| :--- | :--- | :--- | :--- |
Bibliofilm answered 18/1, 2019 at 21:0 Comment(0)
A
15

If anyone still need this:

First way


Single row table for github (README.md) or stackoverflow (post):

| A | B |
|-|-|

output:

A B


Second way


This one is for github markdown - it seems not working on stackoverflow:

<table>
    <tr>
        <td>A</td><td>B</td><td>C</td><td>D</td>
    </tr>
</table>

output:

enter image description here



Third way


You can use another old school way using ASCII chars:
This method is not worth it because you have to sort the characters by hand or write a script for it. But in the worst case, it might help.
Use pre tag for markdown (README.md)

<pre>
╔═══════════════╦═══════════════╗
║       A       ║       B       ║
╚═══════════════╩═══════════════╝
</pre>

<!--OR-->

<pre>
┌───────────────┬───────────────┐
│       A       │       B       │
└───────────────┴───────────────┘
</pre>
Ambagious answered 12/5, 2021 at 15:35 Comment(0)
P
3

This may not be possable. Table syntax is a non-standard Markdown feature. It is not in the official rules, but is supported by many implementations. Of course, given the lack of an official rules, each implementation works slightly differently.

That said, some of the most popular implementations are fairly consistent with only minor variations in their behavior. To name a few, PHP Markdown Extra, GitHub Flavored Markdown, the table extension for Python-Markdown1, and Pandoc's pipe tables all require a header row. In other words you cannot only have one row.

In fact, the table which gitbook visual editor auto-generated is actually a multi-row table. The full syntax for the table would be:

| Windows | Linux x32 | Linux x64 | Mac x64 |
| :------ | :-------- | :-------- | :------ |
|                                           |

Notice that the first two rows consist of a table header and the third row is an empty cell. You will find that not all implementations will automatically add the third (empty) row. Those which do not will not even recognize the one-row version as a table at all. In other words, for most implementations, that is the absolute minimum table you could create.

1 Full disclosure: I am a developer for Python-Markdown.

Pedaiah answered 18/1, 2019 at 21:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.