Skip to content

Rendered Markdown table ignores justify #8609

Description

@AdrienHorgnies

Describe the feature or problem you’d like to solve

Mardown allows justifying a column to the left, center or right.
When view a Markdown file on the command line, the columns are always justified to the left.
Instead, it should abide by the justification set in the header of the table.

See the below table:

Period Day Part Duration
2024-01-21 Evening 6m
2024-01-21 Night 1h55m
2024-01-22 Noon 44m
2024-01-22 Afternoon 2h00m

Assuming you're viewing this issue from a modern Browser,
you should see that the third column is right justified, thanks to the notation ---:.

But when rendered by gh, using for example gh gist view ID where ID references a gist containing a markdown file, we get:

      PERIOD   │ DAY PART  │ DURATION
  ─────────────┼───────────┼───────────
    2024-01-21 │ Evening   │ 6m
    2024-01-21 │ Night     │ 1h55m
    2024-01-22 │ Noon      │ 44m
    2024-01-22 │ Afternoon │ 2h00m

Proposed solution

  • left justified: same as now
  • right justified: pad value from the left using spaces to match width of longest value (see example below)
  • center justified: pad left and right to match width of longest value (if odd number of padding spaces, prefer left padding)
      PERIOD   │ DAY PART  │ DURATION
  ─────────────┼───────────┼───────────
    2024-01-21 │ Evening   │       6m
    2024-01-21 │ Night     │    1h55m
    2024-01-22 │ Noon      │      44m
    2024-01-22 │ Afternoon │    2h00m

Additional context

Add any other context like screenshots or mockups are helpful, if applicable.

Activity

  1. williammartin commented on Feb 21, 2024

    @williammartin
    Member

    Hey @AdrienHorgnies sorry for the slow response after the Christmas vacation. Some team changes and a large backlog to get through. Thanks for opening this issue.

    Just to make sure I understand, what you're saying is that when we apply our markdown renderer, it is not handling the justification that the table header is including. For example, when running gh issue view -R cli/cli 8609 (meta!) we can see the difference between the browser and the CLI rendering:

    Image

    Image

  2. added
    more-info-neededMore info needed from user/contributor
    and removed on Feb 21, 2024
  3. AdrienHorgnies commented on Feb 25, 2024

    @AdrienHorgnies
    Author

    Hi @williammartin ,

    Yes, that's exactly it.

  4. williammartin commented on Feb 26, 2024

    @williammartin
    Member

    Makes sense. I'll check in with the folks at Charm to see whether they have any plans to support this in glamour (our library that renders the markdown). This looks like the most relevant issue: charmbracelet/glamour#117

  5. maaslalani commented on Feb 26, 2024

    @maaslalani

    This should be solved by charmbracelet/glamour#284!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions