Repository: yihui/litedown Branch: main Commit: 42d6af45041e Files: 142 Total size: 557.1 KB Directory structure: gitextract_h5miewmq/ ├── .Rbuildignore ├── .github/ │ ├── copilot-instructions.md │ └── workflows/ │ ├── R-CMD-check.yaml │ ├── copilot-setup-steps.yml │ └── github-pages.yml ├── .gitignore ├── DESCRIPTION ├── LICENSE ├── LICENSE.md ├── Makefile ├── NAMESPACE ├── NEWS.md ├── R/ │ ├── format.R │ ├── fuse.R │ ├── mark.R │ ├── package.R │ ├── preview.R │ ├── site.R │ ├── utils.R │ └── zzz.R ├── README.md ├── docs/ │ ├── 01-start.Rmd │ ├── 02-fuse.Rmd │ ├── 03-syntax.Rmd │ ├── 04-mark.Rmd │ ├── 05-assets.Rmd │ ├── 06-widgets.Rmd │ ├── 07-editor.Rmd │ ├── 08-site.Rmd │ ├── A-misc.Rmd │ ├── _litedown.yml │ └── index.Rmd ├── examples/ │ ├── 001-minimal.Rmd │ ├── 001-minimal.md │ ├── 002-attr-options.Rmd │ ├── 002-attr-options.md │ ├── 003-attr-callout.Rmd │ ├── 003-attr-callout.md │ ├── 004-caption-position.Rmd │ ├── 004-caption-position.md │ ├── 005-option-code.Rmd │ ├── 005-option-code.md │ ├── 006-option-collapse.Rmd │ ├── 006-option-collapse.md │ ├── 007-option-comment.Rmd │ ├── 007-option-comment.md │ ├── 008-option-device.Rmd │ ├── 008-option-device.md │ ├── 009-option-figure-decoration.Rmd │ ├── 009-option-figure-decoration.md │ ├── 010-option-plot-files.Rmd │ ├── 010-option-plot-files.md │ ├── 011-option-label.Rmd │ ├── 011-option-label.md │ ├── 012-option-order.Rmd │ ├── 012-option-order.md │ ├── 013-option-print.Rmd │ ├── 013-option-print.md │ ├── 014-option-purl.R │ ├── 014-option-purl.Rmd │ ├── 014-option-purl.md │ ├── 015-fill-chunk.Rmd │ ├── 015-fill-chunk.md │ ├── 016-option-results.Rmd │ ├── 016-option-results.md │ ├── 017-option-strip-white.Rmd │ ├── 017-option-strip-white.md │ ├── 018-option-table.Rmd │ ├── 018-option-table.md │ ├── 019-option-verbose.Rmd │ ├── 019-option-verbose.md │ ├── 020-inline.Rmd │ ├── 020-inline.md │ ├── 021-simple-datatables.Rmd │ ├── 021-simple-datatables.md │ ├── 022-dygraphs.Rmd │ ├── 022-dygraphs.md │ ├── 023-leaflet.Rmd │ ├── 023-leaflet.md │ ├── 024-chart-js.Rmd │ ├── 024-chart-js.md │ ├── 025-option-filter.Rmd │ ├── 025-option-filter.md │ ├── _run.R │ ├── test-collapse.Rmd │ ├── test-collapse.md │ ├── test-inline.Rmd │ ├── test-inline.md │ ├── test-options.Rmd │ ├── test-options.md │ ├── test-results-hide.Rmd │ └── test-results-hide.md ├── inst/ │ └── resources/ │ ├── default.css │ ├── listing.css │ ├── litedown.html │ ├── litedown.latex │ ├── server.css │ ├── server.js │ ├── snap.css │ └── snap.js ├── litedown.Rproj ├── man/ │ ├── crack.Rd │ ├── engines.Rd │ ├── fuse_book.Rd │ ├── fuse_env.Rd │ ├── fuse_site.Rd │ ├── get_context.Rd │ ├── html_format.Rd │ ├── litedown-package.Rd │ ├── mark.Rd │ ├── markdown_options.Rd │ ├── pkg_desc.Rd │ ├── raw_text.Rd │ ├── reactor.Rd │ ├── roam.Rd │ ├── smartypants.Rd │ ├── timing_data.Rd │ └── vest.Rd ├── playground/ │ ├── _default.Rmd │ └── setup.R ├── site/ │ ├── _footer.Rmd │ ├── _litedown.yml │ ├── action.yml │ ├── articles.Rmd │ ├── code.Rmd │ ├── examples.Rmd │ ├── index.Rmd │ ├── manual.Rmd │ ├── news.Rmd │ └── playground/ │ ├── _default.R │ └── index.html ├── tests/ │ ├── examples.R │ ├── test-cran/ │ │ ├── test-crack.R │ │ ├── test-fuse.R │ │ ├── test-fuse.md │ │ ├── test-mark.R │ │ ├── test-mark.md │ │ ├── test-reactor.R │ │ ├── test-reactor.md │ │ └── test-utils.R │ └── test-cran.R └── vignettes/ └── slides.Rmd ================================================ FILE CONTENTS ================================================ ================================================ FILE: .Rbuildignore ================================================ .gitignore ^.*\.Rproj$ ^\.Rproj\.user$ Makefile ^\.github$ ^LICENSE\.md$ ^docs$ ^examples$ ^playground$ ^site$ .*\.tar\.gz$ .*\.Rcheck$ ================================================ FILE: .github/copilot-instructions.md ================================================ # Repository Instructions for Copilot ## Build and Test Instructions ``` bash # Build the R package R CMD build . # Install the package R CMD INSTALL *_*.tar.gz # Test the package cd tests Rscript *.R ``` Tests are typically in `tests/testit/test-*.R` (for each `R/foo.R`, there is a corresponding `tests/testit/test-foo.R`). In certain cases they may be in other directories, e.g., `tests/test-cran/` (for tests to run on anywhere, including CRAN) and `tests/test-ci/` (tests to run on CI only because they might fail on CRAN due to Internet connection or resource limits). The conditioning is done in top-level `*.R` under `tests/`, e.g., ``` r # tests/test-cran.R testit::test_pkg(dir = 'test-cran') # tests/test-ci.R if (tolower(Sys.getenv('CI')) == 'true') testit::test_pkg(dir = 'test-ci') ``` Tests consist of assertions of this form: ``` r library(testit) assert('expectation message', { actual = FUN(args, ...) (actual %==% expected) # more tests of the above form, e.g., (length(res) %==% 3L) }) ``` - Use `has_error()` instead of `tryCatch()` for error testing - Never use `:::` to access internal functions in tests; testit exposes internal functions automatically, so call them directly ## Important Conventions ### R Code Style 1. **Assignment**: Use `=` instead of `<-` for assignment 2. **Strings**: Use single quotes for strings (e.g., `'text'`) 3. **Indentation**: Use 2 spaces (not 4 spaces or tabs) 4. **Compact code**: Avoid `{}` for single-expression if statements; prefer compact forms when possible 5. **Roxygen documentation**: Don't use `@description` or `@details` explicitly — just write the description text directly after the title. Don't use `@title` either. 6. **Examples**: Avoid `\dontrun{}` unless absolutely necessary. Prefer runnable examples that can be tested automatically. 7. **Function definitions**: For functions with many arguments, break the line right after the opening `(`, indent arguments by 2 spaces, and try to wrap them at 80-char width. 8. **Re-wrap code**: Always re-wrap the code after making changes to maintain consistent formatting and line length. 9. **Implicit NULL**: Don't write `if (cond) foo else NULL`; the `else NULL` is unnecessary since R's `if` without `else` already returns `NULL`. Never write `return(NULL)`; use `return()` instead since R functions return `NULL` by default when no value is given. 10. **US spelling**: Use US spelling throughout all documentation, code comments, and example text (e.g., "color" not "colour", "center" not "centre", "summarize" not "summarise"). 11. **DRY (Don't Repeat Yourself)**: Never duplicate code. When the same logic appears more than once, factor it into a shared helper function. This applies to expressions, patterns, and multi-line blocks alike. ### Check list Always send a pull request, unless you are told otherwise. For each PR: 1. **Every change must have tests**: Every code change must come with corresponding tests. If you add or fix a function, add assertions in the test file that cover the new or fixed behavior. Tests are the first place to catch regressions and errors. 2. **Always re-roxygenize**: Run `roxygen2::roxygenize()` after changing any roxygen documentation to update man files 3. **MANDATORY: `R CMD check` before `git push`**: You MUST run a comprehensive `R CMD check` successfully before submitting ANY code changes. 4. **MANDATORY: Wait for CI to be green**: After pushing code, you MUST wait for GitHub Actions CI to complete successfully before claiming the task is done. Do not wait more than 5 minutes for any single CI job; if it hasn't finished, skip it and continue your work. Fix problems in CI as soon as any job has failed instead of waiting for all jobs to finish. 5. **MANDATORY: Merge latest main before pushing**: Before pushing to a branch or PR, always pull and merge the latest main branch. If there are merge conflicts, resolve them before pushing. 6. **Bump version in PRs**: Bump the patch version number in DESCRIPTION once per PR (on the first commit or when you first make changes), not on every commit to the PR 7. **Never commit irrelevant files**: Don't run `git add .` blindly, as that might add irrelevant files such as generated output or other artifacts. Only add the ones you modified or created explicitly. Normally changes generated automatically by roxygen2 are the only exception (they should be committed). 8. **Update NEWS.md**: When making changes, make sure to update `NEWS.md` accordingly to document what changed. The first heading in NEWS.md always represents the dev version and must be of the form `# PKG x.y` where PKG is the package name and x.y is the next version to be released to CRAN (note: x.y, not x.y.0). Usually y is bumped from the current minor version, e.g., if the current dev version is 1.8.3, the next CRAN release is expected to be 1.9. ================================================ FILE: .github/workflows/R-CMD-check.yaml ================================================ on: push: branches: [main] pull_request: branches: [main] name: R-CMD-check jobs: R-CMD-check: runs-on: ${{ matrix.config.os }} name: ${{ matrix.config.os }} (${{ matrix.config.r }}) strategy: fail-fast: false matrix: config: - {os: ubuntu-latest, r: 'release'} - {os: ubuntu-latest, r: '4.4'} - {os: ubuntu-latest, r: '4.3'} - {os: ubuntu-latest, r: '4.2'} - {os: ubuntu-latest, r: '4.1'} - {os: ubuntu-latest, r: '4.0'} - {os: ubuntu-latest, r: '3.6'} - {os: ubuntu-latest, r: '3.5'} - {os: ubuntu-latest, r: '3.4'} - {os: ubuntu-latest, r: '3.3'} - {os: ubuntu-latest, r: '3.2'} - {os: ubuntu-latest, r: '3.2.0'} - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} - {os: macOS-latest, r: 'release'} - {os: windows-latest, r: 'release'} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} R_KEEP_PKG_SOURCE: yes _R_CHECK_FORCE_SUGGESTS_: false _R_CHECK_RD_XREFS_: false steps: - uses: actions/checkout@HEAD - uses: r-lib/actions/setup-r@HEAD with: r-version: ${{ matrix.config.r }} http-user-agent: ${{ matrix.config.http-user-agent }} use-public-rspm: true - name: Whether to use codecov run: | echo "USE_R_CODECOV=${{ (runner.os == 'Linux' && matrix.config.r == 'release') && true || false }}" >> $GITHUB_ENV - uses: yihui/actions/setup-r-dependencies@HEAD with: # install the package itself as we register vignette engine extra-packages: . ${{ env.USE_R_CODECOV == 'true' && ' covr xml2' || '' }} # install dependencies for cairo_pdf device brew-packages: xquartz - uses: yihui/actions/check-r-package@HEAD - name: Run examples working-directory: examples run: | Rscript _run.R git diff --quiet || (git diff && exit 1) - name: Test coverage if: success() && env.USE_R_CODECOV == 'true' run: | cov = covr::package_coverage( quiet = FALSE, clean = FALSE, install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") ) covr::to_cobertura(cov) xfun::file_string('./cobertura.xml') shell: Rscript {0} - uses: codecov/codecov-action@HEAD if: env.USE_R_CODECOV == 'true' with: fail_ci_if_error: ${{ github.event_name != 'pull_request' }} files: ./cobertura.xml plugins: noop disable_search: true - uses: actions/checkout@HEAD if: runner.os == 'macOS' with: path: gh-pages ref: gh-pages - name: Publish book if: runner.os == 'macOS' run: | Rscript -e 'install.packages("xfun", repos="https://yihui.r-universe.dev")' Rscript -e 'litedown::fuse_book("docs")' cd docs; cp -r *.html ../gh-pages/; cd ../gh-pages git config user.name github-actions git config user.email github-actions@github.com git add . git commit -m "update docs" && git push || true ================================================ FILE: .github/workflows/copilot-setup-steps.yml ================================================ name: Copilot Setup Steps on: workflow_dispatch: push: paths: - .github/workflows/copilot-setup-steps.yml pull_request: paths: - .github/workflows/copilot-setup-steps.yml jobs: copilot-setup-steps: runs-on: ubuntu-latest permissions: contents: read steps: - name: Checkout code uses: actions/checkout@HEAD - name: Install R uses: r-lib/actions/setup-r@HEAD with: use-public-rspm: true - uses: yihui/actions/setup-r-dependencies@HEAD with: extra-packages: roxygen2 . ================================================ FILE: .github/workflows/github-pages.yml ================================================ name: Build and deploy package site on: push: branches: ["main"] permissions: contents: read pages: write id-token: write jobs: deploy: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest steps: - uses: actions/checkout@HEAD - uses: actions/configure-pages@HEAD with: enablement: true - uses: yihui/litedown/site@HEAD with: site-dir: 'site' - uses: actions/upload-pages-artifact@HEAD with: path: 'site' - id: deployment uses: actions/deploy-pages@HEAD ================================================ FILE: .gitignore ================================================ .Rproj.user .Rhistory .RData .Ruserdata /examples/*__files/ /examples/figures/ /site/doc/ /site/_footer.md /docs/packages.bib *.Rcheck/ *.tar.gz ================================================ FILE: DESCRIPTION ================================================ Package: litedown Type: Package Title: A Lightweight Version of R Markdown Version: 0.9.9 Authors@R: c( person("Yihui", "Xie", role = c("aut", "cre"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666", URL = "https://yihui.org")), person("Tim", "Taylor", role = "ctb", comment = c(ORCID = "0000-0002-8587-7113")), person() ) Description: Render R Markdown to Markdown (without using 'knitr'), and Markdown to lightweight HTML or 'LaTeX' documents with the 'commonmark' package (instead of 'Pandoc'). Some missing Markdown features in 'commonmark' are also supported, such as raw HTML or 'LaTeX' blocks, 'LaTeX' math, superscripts, subscripts, footnotes, element attributes, and appendices, but not all 'Pandoc' Markdown features are (or will be) supported. With additional JavaScript and CSS, you can also create HTML slides and articles. This package can be viewed as a trimmed-down version of R Markdown and 'knitr'. It does not aim at rich Markdown features or a large variety of output formats (the primary formats are HTML and 'LaTeX'). Book and website projects of multiple input documents are also supported. Depends: R (>= 3.2.0) Imports: utils, commonmark (>= 2.0.0), xfun (>= 0.55) Suggests: rbibutils, rstudioapi, testit, tinytex License: MIT + file LICENSE URL: https://github.com/yihui/litedown BugReports: https://github.com/yihui/litedown/issues VignetteBuilder: litedown RoxygenNote: 7.3.3 Encoding: UTF-8 Roxygen: list(markdown = TRUE) ================================================ FILE: LICENSE ================================================ YEAR: 2024-2026 COPYRIGHT HOLDER: Yihui Xie ================================================ FILE: LICENSE.md ================================================ # MIT License Copyright (c) 2023 Posit Software, PBC Copyright (c) 2024-2026 Yihui Xie Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: Makefile ================================================ all: ln -f ../lite.js/js/snap.js ../lite.js/css/snap.css ../lite.js/css/default.css inst/resources/ Rscript -e "Rd2roxygen::rab('.', install=TRUE)" rm litedown_*.tar.gz cd examples && Rscript _run.R ================================================ FILE: NAMESPACE ================================================ # Generated by roxygen2: do not edit by hand S3method(print,litedown_env) S3method(record_print,data.frame) S3method(record_print,knitr_kable) S3method(record_print,matrix) S3method(record_print,tbl_df) export(crack) export(engines) export(fiss) export(fuse) export(fuse_book) export(fuse_env) export(fuse_site) export(get_context) export(html_format) export(latex_format) export(mark) export(markdown_options) export(pkg_citation) export(pkg_code) export(pkg_desc) export(pkg_manual) export(pkg_news) export(raw_text) export(reactor) export(roam) export(sieve) export(timing_data) export(vest) import(utils) importFrom(xfun,Rscript_call) importFrom(xfun,alnum_id) importFrom(xfun,base64_uri) importFrom(xfun,csv_options) importFrom(xfun,del_empty_dir) importFrom(xfun,dir_create) importFrom(xfun,divide_chunk) importFrom(xfun,download_cache) importFrom(xfun,exit_call) importFrom(xfun,fenced_block) importFrom(xfun,fenced_div) importFrom(xfun,file_exists) importFrom(xfun,file_ext) importFrom(xfun,grep_sub) importFrom(xfun,html_escape) importFrom(xfun,html_tag) importFrom(xfun,html_value) importFrom(xfun,in_dir) importFrom(xfun,is_abs_path) importFrom(xfun,is_blank) importFrom(xfun,is_rel_path) importFrom(xfun,loadable) importFrom(xfun,mime_type) importFrom(xfun,new_app) importFrom(xfun,new_record) importFrom(xfun,normalize_path) importFrom(xfun,parse_only) importFrom(xfun,prose_index) importFrom(xfun,raw_string) importFrom(xfun,read_all) importFrom(xfun,read_utf8) importFrom(xfun,record_print) importFrom(xfun,relative_path) importFrom(xfun,same_path) importFrom(xfun,sans_ext) importFrom(xfun,set_envvar) importFrom(xfun,split_lines) importFrom(xfun,try_error) importFrom(xfun,try_silent) importFrom(xfun,with_ext) importFrom(xfun,write_utf8) ================================================ FILE: NEWS.md ================================================ # CHANGES IN litedown VERSION 0.10 - When the `output` argument of `mark()` is a `.pdf` file, Markdown will be converted to a full `.tex` file instead of a LaTeX fragment before it is compiled to PDF. - Fixed a bug that sections in the appendix could not be cross-referenced. - Added a meta variable `lang` for HTML output, which is the language of the document (e.g., `en-US` for US English). This variable is used in the `` tag of the HTML output file. By default, the language is detected from the system locale, but you can also set it via the `lang` field under `meta` in YAML metadata, e.g., `lang: en-GB` for British English (thanks, @TimTaylor, #121). - Fixed a bug when embedding JS resources: previously `` from being present in the JS source, but the escaping was too general (e.g., `` to `<\/script>`. - For `fuse_site()`, the generated site menu now automatically includes landing pages for one-level subdirectories containing `index.html` (e.g., `playground/index.html`), so subdirectory index pages appear in the navigation. - Fixed a re-entrancy bug that chunk options `fig.path` and `cache.path` in nested `fuse()` calls caused overridden figure/cache files (thanks, @nanxstats, #127). # CHANGES IN litedown VERSION 0.9 - Provided [a new chunk option `filter`](https://yihui.org/litedown/#sec:option-filter) to filter the output elements via a custom function. This makes it possible to re-order output elements. As a result, text output and plots from a `for`-loop can be interleaved (thanks, @reedacartwright, #106). - The chunk option `attr.source` will default to `.lang` (where `lang` is the engine name) only when it is not provided, i.e., `NULL`. Previously the value `.lang` would still be used when `attr.source` has been provided. Now it's possible to completely override it, e.g., `attr.source = 'language-r'` as in #107 (thanks, @ThomasSoeiro). - The chunk option `collapse = TRUE` also applies to message blocks, including warnings, messages, and errors (thanks, @ThomasSoeiro, #108). - `pkg_desc()` gained a new argument `type` and the package description can be generated to either a table or a definition list now. - The `embed_resources` option was buggy for deferred JS resources. Previously they were moved to ``, but deferred scripts should be executed after the full DOM is ready, so they are moved before `` instead if they are to be embedded. - Fixed a bug in `pkg_manual()` that may lead to omission of certain items when building TOC. # CHANGES IN litedown VERSION 0.8 - Added a new chunk option `fig.keep` to select plots to be kept in a code chunk (thanks, @Gabrielforest, #99). See https://yihui.org/litedown/#sec:option-fig for documentation. - Improved support for LaTeX footnotes. The footnote identifier no longer has to be a number, and the footnote can include arbitrary elements (not necessarily a single paragraph). - The chunk option `results = 'hide'` will imply `collapse = TRUE`, i.e., when text output is hidden, the source blocks will be merged (thanks, @jangorecki, #87). - `fuse(text = '# text')` will be treated as Markdown input instead of R code input (thanks, @chuxinyuan, #102). - Fixed the bug that the chunk option `fig.path` does not work when it does not contain `/` (thanks, @J-Moravec, #88). - `get_context('full_input')` gives the full path to the input file of `fuse()` (thanks, @rikivillalba, #104). # CHANGES IN litedown VERSION 0.7 - `pkg_manual()` will exclude help pages with the keyword `internal` (thanks, @TimTaylor, #78). - `pkg_news()` will add links to Github users and issue numbers if the package is hosted on Github. - Allow `,` and `.` in superscripts and subscripts (thanks, @janlisec, #81). - Special characters in bibliography entries such as `{\"u}` can be correctly read now (thanks, @bastistician). - Fixed a bug that inline code expressions (`` `{lang} expr` ``) cannot be correctly located when the line has leading spaces that are not meaningful. - Deleted vignettes `markdown-examples` and `markdown-output`. They are rendered on the package site now: https://git.yihui.org/litedown/examples/test-options.html # CHANGES IN litedown VERSION 0.6 - Added a Markdown rendering option `offline` to download web resources when this option is set to true, so that the HTML output can be viewed offline (thanks, @TimTaylor, #73). See https://yihui.org/litedown/#sec:offline for more info. - Added a function `get_context()` to query the `fuse()` context such as the input file path or the output format (thanks, @MichaelChirico #67, @vincentarelbundock #70). - Added a function `raw_text()` to output raw text content in a code chunk (thanks, @vincentarelbundock, #69). - Dropped the chunk option `ref.label` and added a new chunk option `fill`, which is more general (`ref.label = "LABEL"` can be achieved by `` `