Github preview with anchors should preview the anchor rather than the top of the file

When you link a Github file with an anchor, the preview which Discourse renders is of the top of the file rather than from the anchor on.

See for instance:

This should preview show the development section, not the top of the readme.

(Not sure whether this is actually a bug.)

3 Likes

I’ve added a pr-welcome here if you’d like to help improve this. :slight_smile:

1 Like

I reviewed this PR and noticed that Discourse attempts to serve content directly from the repository using https://raw.githubusercontent.com , which provides a plain, unstyled raw file (e.g., https://raw.githubusercontent.com/discourse/discourse/main/README.md#development ). For line-specific references (like #L-{line-number} ), it jumps directly to the specified line in the file to display the content. To preview a specific section (e.g., #development , #requirements ), you can specify the line number as shown below:

1 Like