Skip to content

Commit

Permalink
Add heading anchors to rendered release bodies
Browse files Browse the repository at this point in the history
Closes #152
  • Loading branch information
ezzatron committed Aug 24, 2024
1 parent 551ba24 commit cf12a84
Show file tree
Hide file tree
Showing 10 changed files with 181 additions and 32 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ Versioning].
[keep a changelog]: https://keepachangelog.com/
[semantic versioning]: https://semver.org/

## Unreleased

### Added

- [Markdown heading anchors] are now added to release bodies.

[markdown heading anchors]: #markdown-heading-anchors

#### Markdown heading anchors

Anchors are now added to headings in the release body. This makes it possible to
link directly to a specific section of the release body, either from within the
release body itself, or externally once the release is created. You would
probably expect GitHub to do this as a part of its release body rendering, just
like it does for READMEs, but surprisingly it doesn't. So, now this action will
do it for you.

## [v5.2.1] - 2024-06-09

[v5.2.1]: https://github.com/ghalactic/github-release-from-tag/releases/v5.2.1
Expand Down
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,48 @@ with Markdown tag annotation bodies:

git tag-md 1.0.0

##### Markdown heading anchors

GitHub doesn't generate [section links] for Markdown headings in release bodies,
like it does for other Markdown content. This means that you normally can't link
directly to a heading in a release body, or include links to headings in your
release body markdown.

[section links]: https://docs.github.com/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#section-links

This action solves this issue by generating **heading anchors** for each heading
in the release body. These anchors work just like the ones generated for most
Markdown content on GitHub, and can be used to link directly to headings in your
release body.

For example, if you have a heading in your release body like this:

```markdown
#### Support for turbo-encabulators
For a number of years now, work has been proceeding in order to bring perfection
to the crudely conceived idea of a machine that would not only supply inverse
reactive current for use in unilateral phase detractors, but would also be
capable of automatically synchronizing cardinal grammeters. Such a machine is
the Turbo-Encabulator.
```

Then you can link directly to this heading in your release body like so:

```markdown
### Added
- Added support for [turbo-encabulators].
[turbo-encabulators]: #support-for-turbo-encabulators
```

And once the release is published, you can also link directly to the heading in
the release body from external sources by adding the anchor to the end of the
release URL, like so:

https://github.com/ghalactic/github-release-from-tag/releases/v5.3.0#markdown-heading-anchors

##### Markdown line breaks

It's common for tag annotation messages to be "wrapped" at a fixed column width,
Expand Down
92 changes: 76 additions & 16 deletions dist/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions dist/main.js.map

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
"@octokit/action": "^7.0.0",
"@octokit/plugin-retry": "^7.0.0",
"ajv": "^8.17.1",
"github-slugger": "^2.0.0",
"js-yaml": "^4.1.0",
"mdast-util-gfm": "^3.0.0",
"mdast-util-to-markdown": "^2.0.0",
"mdast-util-to-string": "^4.0.0",
"mime-types": "^2.1.35",
"remark": "^15.0.1",
"remark-gfm": "^4.0.0",
Expand Down
Loading

0 comments on commit cf12a84

Please sign in to comment.