{"id":13790539,"url":"https://github.com/shafayetShafee/add-code-files","last_synced_at":"2025-05-12T09:32:47.043Z","repository":{"id":145216553,"uuid":"596697665","full_name":"shafayetShafee/add-code-files","owner":"shafayetShafee","description":"A Quarto filter extension to add contents from external source or code files","archived":false,"fork":false,"pushed_at":"2023-03-16T11:26:02.000Z","size":2816,"stargazers_count":16,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-18T05:38:08.275Z","etag":null,"topics":["quarto","quarto-extension","quarto-filter","quarto-pub","quartopub"],"latest_commit_sha":null,"homepage":"https://shafayetshafee.github.io/add-code-files/example.html","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shafayetShafee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-02-02T18:40:33.000Z","updated_at":"2024-07-25T20:39:17.000Z","dependencies_parsed_at":"2024-01-05T23:51:24.490Z","dependency_job_id":"18743835-bee9-43d6-a7ac-3b4604ef244c","html_url":"https://github.com/shafayetShafee/add-code-files","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shafayetShafee%2Fadd-code-files","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shafayetShafee%2Fadd-code-files/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shafayetShafee%2Fadd-code-files/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shafayetShafee%2Fadd-code-files/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shafayetShafee","download_url":"https://codeload.github.com/shafayetShafee/add-code-files/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253709356,"owners_count":21951123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["quarto","quarto-extension","quarto-filter","quarto-pub","quartopub"],"created_at":"2024-08-03T22:00:46.278Z","updated_at":"2025-05-12T09:32:46.123Z","avatar_url":"https://github.com/shafayetShafee.png","language":"Lua","funding_links":[],"categories":["Extensions"],"sub_categories":[],"readme":"# Add Code Files Extension For Quarto\n\nThis extension provides filter that to add code from source files.\n\n: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.\n\n## Installing\n\n:warning: This extension requires quarto version at least to be 1.2.\n\n```bash\nquarto add shafayetShafee/add-code-files\n```\n\nThis will install the extension under the `_extensions` subdirectory.\nIf you're using version control, you will want to check in this directory.\n\n## Usage\n\nThe 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.\n\nHere is how you add the filter to a quarto document,\n\n```\n---\ntitle: \"Quarto\"\nfilters:\n   - add-code-files\n---\n```\n\n### Including Files\n\nOnce adding the filter to the quarto document, use the `add-from` attribute in a Div containing a empty code-block. For example,\n\n````\n::: {add-from=hello-world.cpp}\n```{.cpp}\n```\n:::\n````\n\nwould 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.\n\nYou can also use the following options,\n\n- **`start-line`**, **`end-line`**: To add a specific range of lines.\n- **`code-line-numbers`**: To enable source code line numbering.\n- **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).\n\n````\n::: {add-from=hello-world.cpp start-line=1 end-line=8 code-line-numbers=\"true\"}\n```{.cpp}\n```\n:::\n````\n\nView the live demo of\n\n- [document rendered with `jupyter`](https://shafayetshafee.github.io/add-code-files/example.html)\n\n- [document rendered with `knitr`](https://shafayetshafee.github.io/add-code-files/example_knitr.html)\n\n### filename and code-filename\n\nYou 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`.\n\nTherefore, use `code-filename` only when using `code-fold: true`, otherwise use `filename` (for non HTML format or for html format without `code-fold: true`)\n\n**`code-filename` only works with `code-folding`. For othercases, use `filename`**\n\nView a [live demo of this issue](https://shafayetshafee.github.io/add-code-files/example_filename.html)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FshafayetShafee%2Fadd-code-files","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FshafayetShafee%2Fadd-code-files","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FshafayetShafee%2Fadd-code-files/lists"}