Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tables): add markdown and ascii border style for tables #480

Open
wants to merge 2 commits into
base: table-resize
Choose a base branch
from

Conversation

andreynering
Copy link
Member

Closes #424

Markdown style:

|----------|--------------|-----------|
| LANGUAGE |    FORMAL    | INFORMAL  |
|----------|--------------|-----------|
| Chinese  | Nǐn hǎo      | Nǐ hǎo    |
| French   | Bonjour      | Salut     |
| Russian  | Zdravstvuyte | Privet    |
| Spanish  | Hola         | ¿Qué tal? |
|----------|--------------|-----------|

ASCII style:

+----------+--------------+-----------+
| LANGUAGE |    FORMAL    | INFORMAL  |
+----------+--------------+-----------+
| Chinese  | Nǐn hǎo      | Nǐ hǎo    |
| French   | Bonjour      | Salut     |
| Russian  | Zdravstvuyte | Privet    |
| Spanish  | Hola         | ¿Qué tal? |
+----------+--------------+-----------+

@andreynering andreynering self-assigned this Feb 26, 2025
@andreynering andreynering linked an issue Feb 26, 2025 that may be closed by this pull request
Copy link
Member

@meowgorithm meowgorithm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! It looks like Markdown wants the bottom and top sections of the Markdown one gone, i.e.

| LANGUAGE |    FORMAL    | INFORMAL  |
|----------|--------------|-----------|
| Chinese  | Nǐn hǎo      | Nǐ hǎo    |
| French   | Bonjour      | Salut     |
| Russian  | Zdravstvuyte | Privet    |
| Spanish  | Hola         | ¿Qué tal? |

Rendered that looks like:

LANGUAGE FORMAL INFORMAL
Chinese Nǐn hǎo Nǐ hǎo
French Bonjour Salut
Russian Zdravstvuyte Privet
Spanish Hola ¿Qué tal?

@andreynering
Copy link
Member Author

Hey @meowgorithm. Thanks for noticing that.

Unfortunately, it seems that it is not possible to address that by just changing that configuration, because:

  1. The char for the divider between headers and data is shared with the top and down char. Changing that makes the rendering of the divider broken.
  2. Even at top and bottom we'd have a bug of having empty lines being printed, instead of ommited.

So, to me, the right solution is to actually disable top and bottom borders with .BorderTop(false).BorderBottom(false). I added both as examples to the README to help the user. What do you think?

@meowgorithm
Copy link
Member

@andreynering Okay yeah, that makes sense. So let's see if docs will suffice for now. If not, we can cautiously consider a shorthand for markdown rendering later.

On that note I'd add the note about .BorderTop(false).BorderBottom(false) to the markdown border GoDocs as well, then this is good to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rendering a markdown table
3 participants