-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
renamed extension name to add-code-files
- Loading branch information
1 parent
5100c34
commit 6ce9964
Showing
39 changed files
with
5,438 additions
and
5,860 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,73 @@ | ||
# Include Code Files Extension For Quarto | ||
# Add Code Files Extension For Quarto | ||
|
||
This extension provides filter that to include code from source files. | ||
This extension provides filter that to add code from source files. | ||
|
||
:information_source: This filter is an alternative to the [include-code-files](https://github.com/quarto-ext/include-code-files) by [@quarto-ext](https://github.com/quarto-ext) with [`code-fold`](https://quarto.org/docs/output-formats/html-code.html#folding-code)-ing capability. If you just want to include contents from another file and do not care about code-folding you probably want to use the former filter, which is simpler to use. | ||
:information_source: This filter is an alternative to the [include-code-files](https://github.com/quarto-ext/include-code-files) by [@quarto-ext](https://github.com/quarto-ext) with [`code-fold`](https://quarto.org/docs/output-formats/html-code.html#folding-code)-ing capability. If you just want to add contents from another file and do not care about code-folding you probably want to use the former filter, which is simpler to use. | ||
|
||
## Installing | ||
|
||
:warning: This extension requires quarto version at least to be 1.2. | ||
|
||
```bash | ||
quarto add shafayetShafe/include-code-files | ||
quarto add shafayetShafe/add-code-files | ||
``` | ||
|
||
This will install the extension under the `_extensions` subdirectory. | ||
If you're using version control, you will want to check in this directory. | ||
|
||
## Usage | ||
|
||
The filter recognizes [Divs](https://quarto.org/docs/authoring/markdown-basics.html#divs-and-spans) or code-chunk with the `include-from` attribute present. It swaps the content of the code block with contents from a file. | ||
The filter recognizes [Divs](https://quarto.org/docs/authoring/markdown-basics.html#divs-and-spans) or code-chunk with the `add-from` attribute present. It swaps the content of the code block with contents from a file. | ||
|
||
Here is how you add the filter to a quarto document, | ||
|
||
``` | ||
--- | ||
title: "Quarto" | ||
filters: | ||
- include-code-files | ||
- add-code-files | ||
--- | ||
``` | ||
|
||
### Including Files | ||
|
||
Once adding the filter to the quarto document, use the `include-from` attribute in a Div containing a empty code-block. For example, | ||
Once adding the filter to the quarto document, use the `add-from` attribute in a Div containing a empty code-block. For example, | ||
|
||
```` | ||
::: {include-from=hello-world.cpp} | ||
::: {add-from=hello-world.cpp} | ||
```{.cpp} | ||
``` | ||
::: | ||
```` | ||
|
||
would include the codes from `hello-world.cpp` within that `.cpp` code block. And you need to use `.cpp` to get correct syntax highlighting for added c++ code. Run `quarto pandoc --list-highlight-languages` to get the list of languages for which syntax highlighting is supported. | ||
would add the codes from `hello-world.cpp` within that `.cpp` code block. And you need to use `.cpp` to get correct syntax highlighting for added c++ code. Run `quarto pandoc --list-highlight-languages` to get the list of languages for which syntax highlighting is supported. | ||
|
||
You can also use the following options, | ||
|
||
- **`start-line`**, **`end-line`**: To include a specific range of lines. | ||
- **`start-line`**, **`end-line`**: To add a specific range of lines. | ||
- **`code-line-numbers`**: To enable source code line numbering. | ||
- **dedent**: using this you can have whitespaces removed on each line, where possible (non-whitespace character will not be removed even if they occur in the dedent area). | ||
|
||
```` | ||
::: {include-from=hello-world.cpp start-line=1 end-line=8 code-line-numbers="true"} | ||
::: {add-from=hello-world.cpp start-line=1 end-line=8 code-line-numbers="true"} | ||
```{.cpp} | ||
``` | ||
::: | ||
```` | ||
|
||
View the live demo of | ||
|
||
- [document rendered with `jupyter`](https://shafayetshafee.github.io/include-code-files/example.html) | ||
- [document rendered with `jupyter`](https://shafayetshafee.github.io/add-code-files/example.html) | ||
|
||
- [document rendered with `knitr`](https://shafayetshafee.github.io/include-code-files/example_knitr.html) | ||
- [document rendered with `knitr`](https://shafayetshafee.github.io/add-code-files/example_knitr.html) | ||
|
||
### filename and code-filename | ||
|
||
You can also use the `filename` attribute to show a name of the file the included code is associated with. But the issue is, the attribute `filename` does not work with `code-folding` as intended for that code block. This filter provides another option `code-filename` which works with `code-folding`. | ||
You can also use the `filename` attribute to show a name of the file the added code is associated with. But the issue is, the attribute `filename` does not work with `code-folding` as intended for that code block. This filter provides another option `code-filename` which works with `code-folding`. | ||
|
||
Therefore, use `code-filename` only when using `code-fold: true`, otherwise use `filename` (for non HTML format or for html format without `code-fold: true`) | ||
|
||
**`code-filename` only works with `code-folding`. For othercases, use `filename`** | ||
|
||
View a [live demo of this issue](https://shafayetshafee.github.io/include-code-files/example_filename.html) | ||
View a [live demo of this issue](https://shafayetshafee.github.io/add-code-files/example_filename.html) | ||
|
6 changes: 3 additions & 3 deletions
6
...ensions/include-code-files/_extension.yml → _extensions/add-code-files/_extension.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
title: Include Code Files | ||
title: Add Code Files | ||
authors: | ||
- name: quarto-ext | ||
- name: Shafayet Khan Shafee | ||
version: 1.0.0 | ||
version: 1.1.0 | ||
quarto-required: ">=1.2" | ||
contributes: | ||
filters: | ||
- include-code-files.lua | ||
- add-code-files.lua | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Oops, something went wrong.