镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Table width adjustment by dash character - #816

Closed
swcho wants to merge 3 commits into
markedjs:masterfrom
swcho:tableWidthByDash
Closed

swcho wants to merge 3 commits into
markedjs:masterfrom
swcho:tableWidthByDash

Conversation

@swcho

@swcho swcho commented Oct 12, 2016

Copy link
Copy Markdown

Hi, I have little idea to determine table column width by dash characters.

For example, if you have next table.

Header 1|Header 2|Header 3|Header 4
:---    |:--:    |--:     |---
Cell 1  |Cell 2  |Cell 3  |Cell 4
*Cell 5*|Cell 6  |Cell 7  |Cell 8

Each column will have 30%, 20%, 20%, 30% width.
The percentage value of width is determined by (row dash count / total dash count) * 100.
So, if you want to have the same column width, you can adjust dash as below

Header 1|Header 2|Header 3|Header 4
:-    |:-:    |-:     |-
Cell 1  |Cell 2  |Cell 3  |Cell 4
*Cell 5*|Cell 6  |Cell 7  |Cell 8

Last but not least, to use this feature you can turn on flag "tableWidth" through options.

I hope this is useful.
Thanks.

swcho and others added 3 commits October 12, 2016 21:26
@joshbruce

Copy link
Copy Markdown
Member

See #980

@iegik

iegik commented Jan 26, 2018

Copy link
Copy Markdown

Duplicate of #266

@iegik

iegik commented Jan 26, 2018 •

Copy link
Copy Markdown

I like, that You also see the benefits from this feature.
As already discussed in #266, and my expectations are:

  • It should not depends too much on viewport size
  • It should not contain additional formatting
  • It should narrow sell with big content if column marked as shorter
  • It should leave column longer, even if content of cell is short when column marked as longer

The counting dashes, for me is the best solution for calculating relative sizes of columns.
As I see, the Markdown main goal is represent formatted text in text form. So, total dash + spaces should represent approximate table width.
width: 100% - is strongly depends of viewport size, we can avoid using of this, by reverse solution: limiting cell sizes by min-width.
Also notice, that some cell should not be limited - they can be stretched automatically.
Any ideas?

@joshbruce

Copy link
Copy Markdown
Member

Closing as not spec-based (don't believe GFM tables has this functionality). Marking as NFU for possible reconsideration during 2.x development.

@joshbruce joshbruce closed this Apr 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants