jupyterlab-myst icon indicating copy to clipboard operation
jupyterlab-myst copied to clipboard

code-block rendering does not work as expected

Open stefaneidelloth opened this issue 2 years ago • 5 comments

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:

https://github.com/executablebooks/myst-vs-code/issues/57

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

stefaneidelloth avatar Aug 03 '23 08:08 stefaneidelloth

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
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! :tada:

welcome[bot] avatar Aug 03 '23 08:08 welcome[bot]

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

agoose77 avatar Aug 10 '23 10:08 agoose77

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!

rowanc1 avatar Aug 10 '23 19:08 rowanc1

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

agoose77 avatar Aug 11 '23 10:08 agoose77

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

  • https://github.com/executablebooks/mystmd/pull/610

rowanc1 avatar Sep 19 '23 18:09 rowanc1