Sitelet https://github.com/starkware-libs/cairo/pull/10151
Skip to content

bugfix(doc): Made inline links with markup point to the url. - #10151

Merged
orizi merged 1 commit into
mainfrom
orizi/06-22-bugfix_doc_made_inline_links_with_markup_point_to_the_url
Jun 23, 2026
Merged

orizi merged 1 commit into
mainfrom
orizi/06-22-bugfix_doc_made_inline_links_with_markup_point_to_the_url

Conversation

@orizi

@orizi orizi commented Jun 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes incorrect destination span computation for inline Markdown links whose labels contain markup (e.g. [**bold**](path)). The ]( boundary separating the label from the destination was assumed to be immediately adjacent to the label's end offset, but when the label contains emphasis or other inline markup, the parser-reported label end does not point directly at ](. The fix searches forward in the raw content string from the label's end to locate the actual ]( before computing the destination range. The content string is now threaded through location_from_link_fields and find_inline_destination_range to enable this lookup.


Type of change

Please check one:

  • Bug fix (fixes incorrect behavior)
  • New feature
  • Performance improvement
  • Documentation change with concrete technical impact
  • Style, wording, formatting, or typo-only change

Why is this change needed?

When a doc comment link label contained bold or italic markers such as [**bold**](path), the computed dest_span pointed to the wrong byte range in the source text. This caused incorrect go-to-definition or hover behavior for those links because the destination text offset was shifted by the length of the markup characters inside the label.


What was the behavior or documentation before?

find_inline_destination_range assumed the destination started exactly 2 bytes after the label's end offset (i.e., immediately after ](). For plain labels this is correct, but for labels with inline markup the Markdown parser reports the label end at the closing ** or *, not at ], so the computed destination range was wrong.


What is the behavior or documentation after?

find_inline_destination_range now scans forward in the raw comment string from the label's end to find the ]( token, then computes the destination range relative to that position. Links like [**bold**](path) and [*em*](path2) now produce correct dest_span values, as verified by the new test cases.


Related issue or discussion (if any)


Additional context

A new test case covering [**bold**](path) and [*em*](path2) in the same doc comment is added to documentation_comment_parser_links.txt to prevent regressions.

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

orizi commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@orizi
orizi marked this pull request as ready for review June 22, 2026 13:23
@cursor

cursor Bot commented Jun 22, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Localized doc-comment parser change for link span math; behavior for plain labels is unchanged when ]( is immediately after the label end.

Overview
Fixes wrong dest_span offsets for inline doc-comment links whose bracket labels include emphasis (e.g. [**bold**](path)).

Instead of assuming the URL starts two bytes after the parser’s label end, find_inline_destination_range now scans the raw comment from that offset for ]( and derives the destination range from there. The doc comment string is passed through location_from_link_fields so inline links can use the source text.

Regression coverage adds expected MarkdownLink spans for [**bold**](path) and [*em*](path2).

Reviewed by Cursor Bugbot for commit 7033bf5. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 63982e5. Configure here.

Comment thread crates/cairo-lang-doc/src/parser.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 63982e5e08

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/cairo-lang-doc/src/parser.rs Outdated
@orizi
orizi force-pushed the orizi/06-22-bugfix_doc_made_inline_links_with_markup_point_to_the_url branch from 63982e5 to 7033bf5 Compare June 22, 2026 13:33
@orizi
orizi enabled auto-merge June 22, 2026 13:34

@TomerStarkware TomerStarkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@TomerStarkware reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).

@orizi
orizi added this pull request to the merge queue Jun 23, 2026
Merged via the queue into main with commit d5c323d Jun 23, 2026
55 checks passed
@orizi
orizi deleted the orizi/06-22-bugfix_doc_made_inline_links_with_markup_point_to_the_url branch June 23, 2026 07:44
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.

3 participants