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

Detect language within fenced code block when echo: fenced #6248

Merged
merged 3 commits into from
Jul 17, 2023

Conversation

cderv
Copy link
Collaborator

@cderv cderv commented Jul 17, 2023

Detect language within fenced code block when echo: fenced is used for code annotationWelcome to the quarto GitHub repo!

closes #6244

This suppose that when echo: fenced there won't be any language on cell and so only class found will be cell-code. In that case we extract from the text content of CodeBlock the language between ```{{lang}}

We could also try to apply the regex no matter the language on the CodeBlock but it felt too wide...

This PR also adds support for HTML and Markdown code cells using HTML comments as comment chars.

@cderv cderv requested a review from dragonstyle July 17, 2023 15:22
@dragonstyle
Copy link
Collaborator

🔥

@dragonstyle dragonstyle merged commit 610457b into main Jul 17, 2023
7 checks passed
@dragonstyle dragonstyle deleted the fix/annotation-echo-fenced branch July 17, 2023 17:25
@dyavorsky
Copy link

dyavorsky commented Apr 2, 2024

@cderv As of 2024.04.02 on Quarto version 1.4.552, I don't believe the support for markdown cells in Code Annotation has been fixed.

In the following example, code annotation does not work when the language is "markdown" (or "html" or "latex") but it does work when the language is most other things, eg "r"

```markdown
# Header        # <1>
This is a test  # <2>
```
1. a header
2. some content

@cderv
Copy link
Collaborator Author

cderv commented Apr 2, 2024

The right comment chars needs to be used. This works

```markdown
# Header       <!-- <1> -->
This is a test  <!-- <2> -->
```
1. a header
2. some content

as in the tests shown in this PR.

HTML use also HTML comment.
LaTeX uses % so this will work

```latex
\usepackage{graphics}  % <1>
```
1. a header

@dyavorsky
Copy link

This make sense. Very helpful -- I appreciate the fast reply! Can I buy you a coffee as a apology for calling you out? :)

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.

Code-annotation does not work with standard r chunks containing echo: fenced
3 participants