Skip to content

Commit 102aa2c

Browse files
committed
set the global css/js for books and sites in the meta variable css2/js2, which can avoid the repetition of some css/js in YAML or _litedown.yml (if users want to completely avoid the global css/js, they can set css2/js2 to null)
1 parent e2cf9cf commit 102aa2c

File tree

6 files changed

+18
-12
lines changed

6 files changed

+18
-12
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: litedown
22
Type: Package
33
Title: A Lightweight Version of R Markdown
4-
Version: 0.5.14
4+
Version: 0.5.15
55
Authors@R: c(
66
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666", URL = "https://yihui.org")),
77
person("Tim", "Taylor", role = "ctb", comment = c(ORCID = "0000-0002-8587-7113")),

R/mark.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,10 @@ build_output = function(format, options, template, meta, ...) {
422422
)
423423
for (i in setdiff(names(defaults), names(meta))) meta[[i]] = defaults[[i]]
424424
# special handling for css/js "files" that have no extensions
425-
for (i in c('css', 'js')) meta[[i]] = resolve_files(c(meta[[i]], acc_var(i)), i)
425+
for (i in c('css', 'js')) {
426+
i2 = paste0(i, '2') # treat css2/js2 as global base (e.g. for sites)
427+
meta[[i]] = resolve_files(c(meta[[i2]], meta[[i]], acc_var(i)), i)
428+
}
426429
}
427430
sub_vars(tpl, meta, ...)
428431
}

R/site.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fuse_site = function(input = '.') {
5252
}
5353
opts = yaml_field(info$yaml, 'html', c('meta', 'options'))
5454
opts[['meta']] = merge_list(list(
55-
css = c(site_css, '@site'), js = site_js,
55+
css2 = c(site_css, '@site'), js2 = site_js,
5656
include_before = nav_menu(info), include_after = format(Sys.Date(), '© %Y')
5757
), opts[['meta']])
5858
opts[['options']] = merge_list(
@@ -255,7 +255,7 @@ fuse_book = function(input = '.', output = NULL, envir = parent.frame()) {
255255
)
256256
})
257257
tweak_options(format, yaml, list(
258-
body_class = '', css = c(site_css, '@book'), js = site_js
258+
body_class = '', css2 = c(site_css, '@book'), js2 = site_js
259259
), toc = length(preview) == 0)
260260
fuse_output(input[1], output, unlist(res), full)
261261
}

docs/_litedown.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ output:
88
toc:
99
depth: 4
1010
meta:
11-
css: ["@default", "@article", "@book", "@book-litedown", "@copy-button", "@heading-anchor", "@key-buttons", "@callout", "@tabsets", "@pages"]
12-
js: ["@sidenotes", "@appendix", "@toc-highlight", "@chapter-toc", "@copy-button", "@external-link", "@heading-anchor", "@right-quote", "@key-buttons", "@callout", "@tabsets", "@pages"]
11+
css: ["@book-litedown", "@key-buttons", "@callout", "@tabsets"]
12+
js: ["@chapter-toc", "@external-link", "@right-quote", "@key-buttons", "@callout", "@tabsets"]

docs/index.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ $$\mathrm{litedown} = \min{\{R\}} + \{D_i\} - \{D_e\} + \{J\}$$
190190

191191
```{mermaid}
192192
#| scope-litedown, echo = FALSE,
193-
#| fig.cap = 'A minimal partial re-implementation of the R Markdown ecosystem as **litedown**.'
193+
#| fig.cap = 'A minimal partial re-implementation of the R Markdown ecosystem as **litedown**, via [Chibaku Tensei](https://naruto.fandom.com/wiki/Chibaku_Tensei) (to [seal the nine tailed beasts](https://youtu.be/IqAD4np1g1s)).'
194194
classDiagram
195195
class litedown {
196196
+HTML/LaTeX

site/examples.Rmd

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ litedown::vest(css = 'https://cdn.jsdelivr.net/gh/yihui/litedown/inst/resources/
77
```
88

99
```{css, echo = FALSE}
10-
.box pre > code {
11-
overflow: hidden;
12-
text-overflow: ellipsis;
13-
background: none;
14-
&:not(:hover) {
10+
.box pre {
11+
& > code {
12+
overflow: hidden;
13+
text-overflow: ellipsis;
14+
background: none;
15+
}
16+
&:not(:focus) code {
17+
cursor: pointer;
1518
display: -webkit-box;
1619
-webkit-box-orient: vertical;
1720
-webkit-line-clamp: 10;

0 commit comments

Comments
 (0)