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

docs: add limitations related to downlit #6297

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/resources/schema/document-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@

Code linking is currently implemented only for the knitr engine
(via the [downlit](https://downlit.r-lib.org/) package).
A limitation of downlit currently prevents code linking
if `code-line-numbers` is also `true`.
A limitation of downlit prevents code linking
if `code-line-numbers` and/or `code-annotations` are set to `true`.
For `code-link` to work properly, `code-line-numbers` and `code-annotations`
require to be set to `false`.
Comment on lines +36 to +37
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't know if you tried but slight side effect.... setting code-annotations: false does also prevent code linking it seems if the annotations are present in the chunk.

Basically, if one wants code linking in a cells, it should not contains any annotation using # <1> syntax.

I don't know why code-annotations: false make code linking not work because I would have thought the HTML would not be changed in that case. (which is the underlying issue with downlit)

I would say that the advice would be

  • For code-link to work properly, code-line-numbers should not be activated on the cell and No code annotations syntax added.

But again, probably a bug that code-annotations still do something... unless this is the # <1> syntax that makes downlit fails... 🤔

Are you observing like me ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

FYI, I made a repository to check various combinations (but only when defining the option in the yaml frontmatter): https://github.com/mcanouil/quarto--code-link--code-annotations

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After checking, code linking is not preventing by the use of code annotations, it is the other way around as I initially described, i.e., code annotation does not work properly when code-linking: true.
image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

FYI, for code-line-numbers, see https://github.com/mcanouil/quarto--code-link--code-line-numbers.
This indeed prevents code linking.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Really weird - I can indeed reproduce and see that code links works in your example, but I maintain that in my previous example it still does not. Did you try ? #6297 (comment)

Simplified example

---
format: 
  html:
    code-link: true
    code-annotations: true
---

```r
stats::rnorm(1) # <1>
stats::rnorm(2) # <2>
```

1. Test 1
2. Test 2 

image

So we should definitely try every possible case and check how that works - for now I don't understand why this would work in the above and not in your case. Looking into it.

Thanks for the repo by the way !

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry it has been a while. Do we need to check more cases for theses options before merging ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have to say, indeed it's been a while and I did not update https://github.com/mcanouil/quarto--code-link--code-line-numbers with your last example.
I'll have to add those tests and check the results.


- name: code-annotations
schema:
Expand Down
Loading