Skip to content

feat: enable some GFM extensions for readme render#1545

Merged
svenstaro merged 2 commits intosvenstaro:masterfrom
duskmoon314:comrak-options
Jan 10, 2026
Merged

feat: enable some GFM extensions for readme render#1545
svenstaro merged 2 commits intosvenstaro:masterfrom
duskmoon314:comrak-options

Conversation

@duskmoon314
Copy link
Copy Markdown
Contributor

@duskmoon314 duskmoon314 commented Jan 9, 2026

This PR enables 4 GFM extensions for --readme to solve #1544 :

  • strikethrough: ~text~ for adding a delete line
  • table: | element | element | for table
  • autolink: render all URLs like https://example.com into <a></a>
  • tasklist: - [ ] foo

Here is a showcase for the current effect:

image

TODO

  • Adjust the CSS to make the table header visible in the default theme.
  • Which extensions should we enable by default? And should we provide an argument to control?

@svenstaro
Copy link
Copy Markdown
Owner

Adjust the CSS to make the table header visible in the default theme.

Please try this out in all of the themes and set reasonable colors :)

Which extensions should we enable by default? And should we provide an argument to control?

I think your selection is fine. I don't think granular control is required.

Previously, table headers used --table_header_text_color only when the
header contained an <a> element. While this worked for listings, tables
in the README fell back to --table_text_color, making headers invisible
under the Squirrel theme.

This change applies --table_header_text_color to all <th> elements by
default.
@duskmoon314
Copy link
Copy Markdown
Contributor Author

Please try this out in all of the themes and set reasonable colors :)

I looked into style.scss, and found out that --table_header_text_color was used only if <a> is in a <th>:

table thead tr th,
table tbody tr td {
  padding: 0.5625rem 0.625rem;
  font-size: 0.875rem;
  color: var(--table_text_color);
  text-align: left;
  line-height: 1.125rem;
}

table thead tr th {
  padding: 0.5rem 0.625rem 0.625rem;
  font-weight: bold;
}

// Other styles

th a,
th a:visited,
.chevron {
  color: var(--table_header_text_color);
}

So I add the color to table thead tr th:

table thead tr th {
  padding: 0.5rem 0.625rem 0.625rem;
  font-weight: bold;
  color: var(--table_header_text_color);
}

Thus, the theme squirrel has different colors for the table's header background and text in the README.

Other themes use the same color or a slightly different color (#f8f8f0 vs #f8f8f2) for text and header text, so the header is visible in the previous commit. Now they are still visible.

@duskmoon314 duskmoon314 marked this pull request as ready for review January 10, 2026 03:42
@svenstaro
Copy link
Copy Markdown
Owner

Do you have a test file for me so I can reproduce your exact results?

@duskmoon314
Copy link
Copy Markdown
Contributor Author

Do you have a test file for me so I can reproduce your exact results?

I just added these lines to this repo's README and executed cargo run -r -- --readme .:

~strikethrough~

| foo | bar |
| --- | --- |
| baz | qux |

- [ ] foo
- [x] bar

https://example.com

As for the CI test, should I write code in tests/readme.rs to check the content? Maybe as follows:

  • strikethrough: check <del> in the <div id="readme-contents">
  • todo: check <input type="checkbox">
  • table: check <th>
  • url: check <a>

@svenstaro svenstaro merged commit 81fa3d8 into svenstaro:master Jan 10, 2026
18 checks passed
@svenstaro
Copy link
Copy Markdown
Owner

This is great! Thanks. I don't think we necessarily need a test for this.

svenstaro added a commit that referenced this pull request Jan 10, 2026
@duskmoon314 duskmoon314 deleted the comrak-options branch January 10, 2026 12:32
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.

2 participants