Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Aligns directive'sblock_text content to rST's#1048

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
kdeldycke wants to merge1 commit intoexecutablebooks:master
base:master
Choose a base branch
Loading
fromkdeldycke:fix-directive-block-text

Conversation

kdeldycke
Copy link

@kdeldyckekdeldycke commentedSep 10, 2025
edited
Loading

In rST, a directive'sblock_text contains the entire directive, including options and full, unparsed content.

This aligns MyST parser to rST.

Context

I stumbled upon this issue while implementing my ownclick:example andclick:run directives within my Click Extra project:https://kdeldycke.github.io/click-extra/sphinx.html

My implementation is trying to report, within these directives, of the absolute line in the document where a problem occured. The line number and offset calculation works perfectly in rST, butrequires some hacks to report the right one in MyST.

But even with these hacks, there is no way to retro-actively compute the absolute line number, because the directive object do not carry its unparsed content.

Example

Compare a given rST directive defined as:

 ..click:run:::linenos:    # This should fail due to variable conflict.    isolated_filesystem = "Do not overwrite me!"

Its properties are:

>>>print("\n".join(directive.content))# This should fail due to variable conflict.isolated_filesystem = "Do not overwrite me!">>>print(directive.block_text).. click:run::    :linenos:    # This should fail due to variable conflict.    isolated_filesystem = "Do not overwrite me!"

And for its MyST equivalent:

```{click:run}:linenos:# This should fail due to variable conflict.isolated_filesystem = "Do not overwrite me!"```
>>>print("\n".join(directive.content))# This should fail due to variable conflict.isolated_filesystem = "Do not overwrite me!">>>print(directive.block_text)# This should fail due to variable conflict.isolated_filesystem = "Do not overwrite me!"

Limitations

Note that it is not perfect, as it is supposed to also contain:

  • the complete directive header (i.e the ```{name} {arguments} first line), and
  • the directive closing line (i.e. the``` line).

But I doubt we can find a way to do it unless we introduce heavier refactor.

kdeldycke added a commit to kdeldycke/click-extra that referenced this pull requestSep 10, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@kdeldycke

[8]ページ先頭

©2009-2025 Movatter.jp