Skip to content

Commit 6ce9964

Browse files
renamed extension name to add-code-files
1 parent 5100c34 commit 6ce9964

39 files changed

+5438
-5860
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,73 @@
1-
# Include Code Files Extension For Quarto
1+
# Add Code Files Extension For Quarto
22

3-
This extension provides filter that to include code from source files.
3+
This extension provides filter that to add code from source files.
44

5-
: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.
5+
: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.
66

77
## Installing
88

99
:warning: This extension requires quarto version at least to be 1.2.
1010

1111
```bash
12-
quarto add shafayetShafe/include-code-files
12+
quarto add shafayetShafe/add-code-files
1313
```
1414

1515
This will install the extension under the `_extensions` subdirectory.
1616
If you're using version control, you will want to check in this directory.
1717

1818
## Usage
1919

20-
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.
20+
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.
2121

2222
Here is how you add the filter to a quarto document,
2323

2424
```
2525
---
2626
title: "Quarto"
2727
filters:
28-
- include-code-files
28+
- add-code-files
2929
---
3030
```
3131

3232
### Including Files
3333

34-
Once adding the filter to the quarto document, use the `include-from` attribute in a Div containing a empty code-block. For example,
34+
Once adding the filter to the quarto document, use the `add-from` attribute in a Div containing a empty code-block. For example,
3535

3636
````
37-
::: {include-from=hello-world.cpp}
37+
::: {add-from=hello-world.cpp}
3838
```{.cpp}
3939
```
4040
:::
4141
````
4242

43-
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.
43+
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.
4444

4545
You can also use the following options,
4646

47-
- **`start-line`**, **`end-line`**: To include a specific range of lines.
47+
- **`start-line`**, **`end-line`**: To add a specific range of lines.
4848
- **`code-line-numbers`**: To enable source code line numbering.
4949
- **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).
5050

5151
````
52-
::: {include-from=hello-world.cpp start-line=1 end-line=8 code-line-numbers="true"}
52+
::: {add-from=hello-world.cpp start-line=1 end-line=8 code-line-numbers="true"}
5353
```{.cpp}
5454
```
5555
:::
5656
````
5757

5858
View the live demo of
5959

60-
- [document rendered with `jupyter`](https://shafayetshafee.github.io/include-code-files/example.html)
60+
- [document rendered with `jupyter`](https://shafayetshafee.github.io/add-code-files/example.html)
6161

62-
- [document rendered with `knitr`](https://shafayetshafee.github.io/include-code-files/example_knitr.html)
62+
- [document rendered with `knitr`](https://shafayetshafee.github.io/add-code-files/example_knitr.html)
6363

6464
### filename and code-filename
6565

66-
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`.
66+
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`.
6767

6868
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`)
6969

7070
**`code-filename` only works with `code-folding`. For othercases, use `filename`**
7171

72-
View a [live demo of this issue](https://shafayetshafee.github.io/include-code-files/example_filename.html)
72+
View a [live demo of this issue](https://shafayetshafee.github.io/add-code-files/example_filename.html)
7373

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
title: Include Code Files
1+
title: Add Code Files
22
authors:
33
- name: quarto-ext
44
- name: Shafayet Khan Shafee
5-
version: 1.0.0
5+
version: 1.1.0
66
quarto-required: ">=1.2"
77
contributes:
88
filters:
9-
- include-code-files.lua
9+
- add-code-files.lua
1010

1111

_extensions/include-code-files/include-code-files.lua renamed to _extensions/add-code-files/add-code-files.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ local str = pandoc.utils.stringify
22

33
local function ensureHtmlDeps()
44
quarto.doc.add_html_dependency({
5-
name = "include-code-files",
5+
name = "add-code-files",
66
version = "1.0.0",
77
scripts = {
8-
{ path = "resources/js/include-code-files.js", afterBody = true}
8+
{ path = "resources/js/add-code-files.js", afterBody = true}
99
},
10-
stylesheets = {"resources/css/include-code-files.css"}
10+
stylesheets = {"resources/css/add-code-files.css"}
1111
})
1212
end
1313

@@ -68,8 +68,8 @@ end
6868
-- gets the necessary chunk option and apply the source_include function with
6969
-- these.
7070
function Div(el)
71-
if el.attributes['include-from'] then
72-
local filepath = str(el.attributes['include-from'])
71+
if el.attributes['add-from'] then
72+
local filepath = str(el.attributes['add-from'])
7373
local startLine = el.attributes['start-line']
7474
local endLine = el.attributes['end-line']
7575
local dedent_line = el.attributes.dedent

0 commit comments

Comments
 (0)