Skip to content

Fix line and column numbers in Markdown files - #5803

Open
d-biehl wants to merge 1 commit into
robotframework:masterfrom
d-biehl:markdown-positions
Open

d-biehl wants to merge 1 commit into
robotframework:masterfrom
d-biehl:markdown-positions

Conversation

@d-biehl

@d-biehl d-biehl commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the quick feedback on #5801! As discussed there, this fixes both line and column numbers, with a few short unit tests this time. 🙂

  • Lines outside robotframework/robot code blocks are replaced with empty lines, so line numbers match the file.
  • Indentation removed from indented code blocks (e.g. in list items) is added back to token column offsets.
  • RobotParser now creates models in a shared _get_model method that MarkdownParser overrides.
  • Expected line numbers in the Markdown acceptance tests now point to the actual lines in the files.

Documentation uses column offsets to keep indentation, so documentation that continues into a more indented code block now gets that extra indentation. This should hardly ever happen.

Fixes #5801.

AI disclosure: I used AI assistance to implement this change and its tests. I reviewed and tested everything myself.

Copilot AI balanced review requested due to automatic review settings September 29, 2026 10:03

Copilot AI 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.

Copilot review overview

🟢 Approval recommended

The implementation consistently corrects source positions and includes focused unit and acceptance coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes Markdown source positions by preserving file lines and restoring dedented column offsets.

Changes:

  • Centralizes model creation in RobotParser._get_model.
  • Corrects Markdown token line and column positions.
  • Adds unit coverage and updates acceptance expectations.
File Description
src/​robot/​running/​builder/​parsers.py Preserves Markdown positions during parsing.
utest/​running/​test_markdownparser.py Tests extraction and source positions.
atest/​robot/​parsing/​data_formats/​markdown.robot Updates expected error lines.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

This branch has not been deployed

No deployments
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.

Tests in Markdown files get line numbers relative to the code blocks, not to the file

2 participants