Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code-block rendering does not work as expected #174

Open
stefaneidelloth opened this issue Aug 3, 2023 · 5 comments
Open

code-block rendering does not work as expected #174

stefaneidelloth opened this issue Aug 3, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@stefaneidelloth
Copy link

stefaneidelloth commented Aug 3, 2023

code-block rendering should support line numbers and highlighting.

JupyterLab Preview:

image

Output of similar code block with latexpdf in Sphinx:

image

For VsCodium preview see related issue ticket:

executablebooks/myst-vs-code#57

(My preffered IDE would be PyCharm but it does not seem to support MyST directives.)

@stefaneidelloth stefaneidelloth added the bug Something isn't working label Aug 3, 2023
@welcome
Copy link

welcome bot commented Aug 3, 2023

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.

If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).

Welcome to the EBP community! 🎉

@agoose77
Copy link
Collaborator

This feature does work, but it differs between MyST-JS and Sphinx. We should ensure that they behave the same, although Sphinx has quirks.

@rowanc1 the following code blocks look different in Sphinx and MyST-JS:

```{code-block}
:lineno-start: 10
:linenos:
:emphasize-lines: 12,13

1, 2, 3
4
5
6
7
```

```{code-block}
:lineno-start: 10
:emphasize-lines: 12,13

1, 2, 3
4
5
6
7
```

```{code-block}
:lineno-start: 10
:emphasize-lines: 2,3

1, 2, 3
4
5
6
7
```

Sphinx:
image

jupyterlab-myst:
image

It looks like Sphinx doesn't use lineno-start as a programmatic offset (only visually). Also, Sphinx uses the presence of lineno-start to activate line numbers . Do you think we can bring these into alignment?

I'm running out of cycles to do this right now, but it looks simple enough:

  • This needs adjusting to lookup the line subtracted by the offset
  • This needs to consider lineno-start for showLineNumbers

@rowanc1
Copy link
Member

rowanc1 commented Aug 10, 2023

Ha, I remember explicitly testing that the offset worked properly and the lines we were highlighting were the same!! Happy to take that out and revert to how sphinx works here. Adding a warning about highlighting lines outside the visible region could also be good!

@agoose77
Copy link
Collaborator

Right - I personally think our implementation is the right one, but I know that we won't change sphinx on this 😅

@rowanc1
Copy link
Member

rowanc1 commented Sep 19, 2023

I have fixed the first portion of the bug lineno-start turning on showLineNumbers in:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants