quarto-ext / include-code-files

Quarto extension to include code from source files.
MIT License
52 stars 6 forks source link

code-fold: true is not working for the chunk with included code from external script #1

Open shafayetShafee opened 1 year ago

shafayetShafee commented 1 year ago

While this filter does include codes from an External file, code-fold: true or code-summary: "some text" is not working for that code chunk (that includes the source code). A quick reproducible example is as follows,

test.py

# code from test.py
for name in ["Sam", "Jake"]:
    print(f"Hello {name}!")

test.qmd

---
title: "Including Code"
format:
  html:
    code-fold: true
    code-summary: "Python Code"
jupyter: python3
filters: 
  - include-code-files
---

## Python

```{.python include="test.py"}
```

```{python}
print("Hello World")
```

output

image

I am using Quarto version,

$ quarto --version
1.2.235

Thanks.

ProtossGP32 commented 1 year ago

Facing the same problem here. It would be great if the extension was compatible with code-folding as some files can be very long.

shafayetShafee commented 1 year ago

I have created the filter include-code-files extending this filter include-code-files by @quarto-ext, so that included code blocks can be folded with code-fold: true and also provided an option so that filename works fine along with code-folding.

cderv commented 1 year ago

@shafayetShafee that is cool !

do you want /plan to make PR into this extension or rather keep your modification in another extension with the same name ?

We welcome any contribution by the community, especially in our extension as we don't have as much time to spend on it when we are focusing on quarto-cli core development.

shafayetShafee commented 1 year ago

I have already implemented my changes as another extension with the same name include-code-files and made an PR to quarto-web repo to enlist this extension the name add-code-files.

cderv commented 1 year ago

I'll keep this open for now as I think this extension should support that directly at some point.