Skip to content

Commit

Permalink
document the copy button and tabsets
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed Dec 21, 2024
1 parent 797d83a commit 502e529
Show file tree
Hide file tree
Showing 6 changed files with 468 additions and 201 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: litedown
Type: Package
Title: A Lightweight Version of R Markdown
Version: 0.4.11
Version: 0.4.12
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666", URL = "https://yihui.org")),
person("Tim", "Taylor", role = "ctb", comment = c(ORCID = "0000-0002-8587-7113")),
Expand Down
3 changes: 1 addition & 2 deletions docs/02-fuse.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,7 @@ Below is an example of using options `attr.chunk`, `attr.source`, and

`{r} .ex(2)`

Here is an example of creating a callout (@sec:callout-blocks) from a code
chunk:
Here is an example of creating a callout (@sec:callout) from a code chunk:

`{r} .ex(3)`

Expand Down
19 changes: 11 additions & 8 deletions docs/03-syntax.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ it is[^03-syntax-1] by yourself after reading its specifications at
Norwegian](https://news.ycombinator.com/item?id=36745212) until YAML 1.2.

What we introduce in this section is a significantly trimmed-down version of
YAML used by **litedown**. For now, let's call it TRACY, a recursive acronym for
"TRACY Really Ain't Complete YAML" and also in honor of [Tracy
YAML. Its official name is "TRACY", a recursive acronym for "TRACY Really Ain't
Complete YAML" and also in honor of [Tracy
Teal](https://en.wikipedia.org/wiki/Tracy_Teal) since she was once a nice boss
of mine.
of mine. However, to follow the naming convention of `*ML`, we use the name
"TAML" (with apologies for the further recursion) when the audience has some
software background.

The following example shows all types of data that TRACY supports:
The following example shows all types of data that TAML supports:

``` yaml
a: 1
Expand All @@ -52,7 +54,7 @@ i:
any_character.is-okay: string not quoted
```
The TRACY specifications are:
The TAML specifications are:
1. Each line should be of the form `field: value`. The `field` name can use any
character. The `value` cannot span across multiple lines. If a line starts
Expand Down Expand Up @@ -85,19 +87,20 @@ The TRACY specifications are:
multiple chidren indented to the same level, and each child can have its
children (further indented by $n$ spaces).

[^03-syntax-2]: TRACY is a good friend of Norwegian.
[^03-syntax-2]: TAML is a good friend of Norwegian.

[^03-syntax-3]: Most people may want to use 2 or 4 spaces. Avoid 8, because that
has been reserved for a VIP in the R club, [Roger
Peng](https://simplystatistics.org/posts/2018-07-27-why-i-indent-my-code-8-spaces/).
You may also choose to use tabs. If you *really* want to, you can mix tabs
with spaces (then $n$ is the total number of them). If people tell you that
you are crazy by mixing up things, don't listen and never follow. TRACY is
you are crazy by mixing up things, don't listen and never follow. TAML is
human-friendly and respects the space right of all human beings. Guess what
happens if you indent one line by 2 spaces and the next line by 3 spaces
when you meant to use 4 spaces?

See @sec:yaml-metadata for all possible fields supported in **litedown**.
TAML is implemented in `xfun::taml_load()` and used by **litedown**. See
@sec:yaml-metadata for all possible fields supported in **litedown**.

## Basic Markdown {#sec:markdown-basic}

Expand Down
69 changes: 46 additions & 23 deletions docs/04-mark.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ resources are not. This means the output document may not work offline. If you
have to view the output offline, you need to use the option value `"https"` (or
`"all"`) and render the document at least once before you go offline.

For `https` resources, after you have embedded them successfully once, they will
be cached locally (via `xfun::download_cache`) and will not require an Internet
connection again.

### `js_highlight`

Specify the JavaScript library to syntax highlight code blocks. Possible values
Expand Down Expand Up @@ -466,49 +470,68 @@ templates:

The following variables are for HTML templates:

#### The `css` variable
#### The `css` variable {#sec:meta-css}

A vector of CSS files to be included in the output. The default value is
`litedown:::pkg_file('resources', 'default.css')`.
A vector of CSS files to be included in the output. If the variable is not
provided, the
[`default.css`](https://github.com/yihui/lite.js/blob/main/css/default.css) will
be used.

If you want to use built-in CSS files in this package, you can only specify the
base name, e.g., `default` means `default.css` in this package.
base name, e.g., `default` means `default.css` in this package, and `snap` means
`snap.css`.

You can also use web resources, e.g., `https://example.org/style.css`. One
special case is [jsdelivr](https://www.jsdelivr.com) resources: if a `css` value
starts with `@`, it will be recognized as a jsdelivr.com resource. if you are
not familiar with jsdelivr, you may read its documentation to understand the
following example URLs. The shorthand syntax is as follows (`CDN` stands for
`https://cdn.jsdelivr.net`):
You can also use web resources via a full URL, e.g.,
`https://example.org/style.css`. One special case is
[jsdelivr](https://www.jsdelivr.com) resources: if a `css` value starts with
`@`, it will be treated as a jsdelivr resource. if you are not familiar with
jsdelivr, you may read its documentation to understand the following example
URLs. The shorthand syntax is as follows (`*` stands for
`https://cdn.jsdelivr.net`) and summarized in @tab:at-syntax:

- `@foo` (without a filename extension) will be converted to
`CDN/npm/@xiee/utils/css/foo.min.css`, e.g., `@default` means
`CDN/npm/@xiee/utils/css/default.min.css`. If you prefer the `.css`
extension over `.min.css`, you can use `@default.css`.
`*/npm/@xiee/utils/css/foo.min.css`, e.g., `@default` means
`*/npm/@xiee/utils/css/default.min.css`. If you prefer the `.css` extension
over `.min.css`, you can use `@default.css`.

- `@foo@version` (a filename followed by a version number) will be converted
to `CDN/npm/@xiee/utils@version/css/foo.min.css`, e.g., `@[email protected]`
means `CDN/npm/@xiee/[email protected]/css/article.min.css`.
to `*/npm/@xiee/utils@version/css/foo.min.css`, e.g., `@[email protected]`
means `*/npm/@xiee/[email protected]/css/article.min.css`.

- `@path/to/file` (i.e., a value that contains slashes) will be converted to
`CDN/path/to/file`, e.g., `@npm/@xiee/utils/js/center-img.js` will be
converted to `CDN/npm/@xiee/utils/js/center-img.min.js`.
`*/path/to/file`, e.g., `@npm/@xiee/utils/js/center-img.js` will be
converted to `*/npm/@xiee/utils/js/center-img.min.js`.

- `@path/to/file-1,file-2` (comma-separated values and later values do not
contain slashes) will be converted to
`CDN/combine/path/to/file-1,path/to/file-2` (this can be useful to
`*/combine/path/to/file-1,path/to/file-2` (this can be useful to
[combine](https://www.jsdelivr.com/documentation#id-combine-multiple-files)
multiple resources and load all at once).

- `@path-1/to/file-1,path-2/to/file-2` (comma-separated values and later
values contain slashes) will be converted to
`CDN/combine/path-1/to/file-1,path-2/to/file-2`.
`*/combine/path-1/to/file-1,path-2/to/file-2`.

:::: {.table .box}
::: caption
[ ](#@tab:at-syntax) The `@` syntax for using jsdelivr resources in the `css`
variable.
:::

| syntax | actual URL |
|----|----|
| `@foo` | `*/npm/@xiee/utils/css/foo.min.css` |
| `@foo.css` | `*/npm/@xiee/utils/css/foo.css` |
| `@foo@version` | `*/npm/@xiee/utils@version/css/foo.min.css` |
| `@path/to/file` | `*/path/to/file` |
| `@path/to/file-1,file-2` | `*/combine/path/to/file-1,path/to/file-2` |
| `@path-1/to/file-1,path-2/to/file-2` | `*/combine/path-1/to/file-1,path-2/to/file-2` |
::::

This provides a way to reduce the output HTML file size by loading CSS from the
web instead of embedding inside HTML, at the cost of requiring Internet
connection when viewing the HTML file. If you need the external web resources to
work after you go offline, you can enable `"https"` in the Markdown option
`embed_resources` in advance to embed the resources.
work after you go offline, please see @sec:embed-resources.

#### The `js` variable

Expand Down Expand Up @@ -568,8 +591,8 @@ output:

### Other fields in YAML

See the help page `?html` for possible fields in addiction to `meta` and
`options` that can be specified under the format name, e.g.,
See the help page `?litedown::html_format` for possible fields in addiction to
`meta` and `options` that can be specified under the format name, e.g.,

``` yaml
output:
Expand Down
Loading

0 comments on commit 502e529

Please sign in to comment.