Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Link to Markdown line on Bitbucket

+3
−0

Is there a way to link to specific code lines for a Markdown file[1] in Bitbucket? I have found a UI toggle for each of GitHub, GitLab, and Forgejo that adds a query string to disable the pretty output,[2] but nothing for Bitbucket.

Interestingly, using various values for ?viewer= causes the whole file preview to disappear, but that might be a red herring.


  1. Markdown, SVG, etc. Any file with a special rendered mode. ↩︎

  2. The pretty output is nice! I like it most of the time... but sometimes I want the code lines. ↩︎

History

0 comment threads

1 answer

+2
−0

It looks like they do have...something. From https://support.atlassian.com/bitbucket-cloud/docs/hyperlink-to-source-code-in-bitbucket/:

URI Template for src

{+bitbucket}{/owner, repository_name}/src{/commitish}{/filepath}{?fileviewer}{#fileline}

Despite the flakiest syntax for describing a URL that I have ever seen, up to the query string represents a normal URL to a file in some repository. The fileviewer query variable specifies a specific view for the file, I gather, but I gather that you don't care about that, though it may (I didn't investigate) affect the output difference that you mention.

The last piece, then, is the key, where they describe fileline as...

The target file name plus the line number, separated by a dash. Without the fileline segment, the URL simply navigates to the target file.

To confirm that they did mean to say "just repeat the name back-to-back for no clear reason," they supply an example of test_auth.py-29. Slap a pound sign in front of that, and you have your specific-line link.

Searching for a random project on Bitbucket to test, then picking a file arbitrarily, I could use that template to verify that it works with https://bitbucket.org/dismine/valentina/src/master/.travis.yml#.travis.yml-29.

If you want a generic approach that'll work anywhere (in other words, doesn't require whatever magic Bitbucket's back-end does to direct to the line without adding an HTML anchor), you can also use the new HTML text highlighting, replacing the file-and-line offset with the horrifying-looking #:~:text= and the text of the line that interests you. For example, you can link to anything on this page, such as https://software.codidact.com/posts/295206#:~:text=most of the time.

History

1 comment thread

Specific to "rendered" files (1 comment)

Sign up to answer this question »