file_path
stringlengths
3
280
file_language
stringclasses
66 values
content
stringlengths
1
1.04M
repo_name
stringlengths
5
92
repo_stars
int64
0
154k
repo_description
stringlengths
0
402
repo_primary_language
stringclasses
108 values
developer_username
stringlengths
1
25
developer_name
stringlengths
0
30
developer_company
stringlengths
0
82
js/learn-arith.js
JavaScript
(function() { let s = document.getElementById('arith'); if (!s) { s = document.currentScript; if (!s) return alert('抱歉,本程序不支持您的古董浏览器,请尝试使用 Chrome/Firefox/Edge 等现代浏览器'); } document.querySelector('.arith') || s.insertAdjacentHTML('afterend', '<style type="text/css">' + '.arith{border:none}.arith tr:nth-child(even){background:none;}' + '.arith.correct *{color:forestgreen;}.arith.wrong *{color:orangered;}' + '.arith thead{font-size:3em;text-align:center;}#number-ans{width:4em;padding:.1em;font-size:inherit;}' + '#arith-go{padding:.1em .2em;vertical-align:middle;font-size:0.8em;}' + '#arith-type{padding:.2em;}.arith input[type="number"]{padding:.2em;width:3em;}</style>' + '<table class="arith fullwidth"><thead><tr><td><span id="number-1">?</span></td>' + '<td><span id="number-op">+</span></td>' + '<td><span id="number-2">?</span></td>' + '<td><span>= </span><input type="number" id="number-ans" /></td>' + '<td><button type="button" id="arith-go">开始</button></td></tr></thead>' + '<tbody><tr><td><label for="digit-1">位数</label></td>' + '<td><label for="arith-type">运算</label></td>' + '<td><label for="digit-2">位数</label></td><td>成绩</td><td>正确率</td></tr>' + '<tr><td><input type="number" id="digit-1" min="1" value="1" /></td>' + '<td><select id="arith-type">' + '<option value="+">+</option><option value="-">-</option>' + '<option value="×">×</option><option value="÷">÷</option>' + '</select></td>' + '<td><input type="number" id="digit-2" min="1" value="1" /></td>' + '<td id="arith-score">?</td><td id="arith-pct">?</td></tr></tbody></table>'); const d = document.querySelector('.arith'), op = d.querySelector('#number-op'), score = d.querySelector('#arith-score'), type = d.querySelector('#arith-type'), res = d.querySelector('#number-ans'), n1 = d.querySelector('#number-1'), n2 = d.querySelector('#number-2'), d1 = d.querySelector('#digit-1'), d2 = d.querySelector('#digit-2'), bt = d.querySelector('#arith-go'), pc = d.querySelector('#arith-pct'); let v1, v2, N = 0, R = 0; // 从 0 到 n - 1 的随机数 function randN(N) { return Math.floor(Math.random() * N); } // 生成给定位数的随机数 function genNum(n) { const a = 10 ** (n - 1); return a + randN(9 * a); } function addQuiz() { const w1 = +d1.value, w2 = +d2.value; if (w1 <= 0) d1.value = w1 = 1; if (w2 <= 0) d2.value = w2 = 1; v1 = genNum(w1); v2 = genNum(w2); const t = type.value; // 如果减数大于被减数,则把两个数字换一下顺序 if (t === '-' && v2 > v1) { const v = v2; v2 = v1; v1 = v; } // 保证能整除,不保证第一个数字能符合位数设定 if (t === '÷') { const v = Math.ceil(v1 / v2) * v2; v1 = v.toFixed(0).length === +d1.value ? v : (Math.floor(v1 / v2) * v2); } n1.innerText = v1; n2.innerText = v2; op.innerText = type.value; d.classList.remove('correct', 'wrong'); res.disabled = false; res.value = ''; res.focus(); } // 点击按钮出新题 bt.addEventListener('click', function(e) { addQuiz(); ++N; }); const lb = ['继续', '再来', '加油', '好的', '走你', '嘿哟', '挺住', '瞄瞄', '汪汪', '服了', '可以', '满分', '聪明', '优秀', '不错', '行啊', '厉害', '真棒', 'Good', 'Perfect', 'Excellent', '你牛', '佩服', '哎呀']; // 输入答案后验证是否正确 res.addEventListener('change', function(e) { const t = type.value, ans = t === '+' ? v1 + v2 : ( t === '-' ? v1 - v2 : ( t === '×' ? v1 * v2 : ( t === '÷' && v1 / v2))); d.classList.add(ans === +res.value ? (++R, 'correct') : 'wrong'); score.innerText = '对 ' + R + ' / 错 ' + (N - R) + ' / 总 ' + N; pc.innerText = Math.round(R / N * 100) + ' %'; res.disabled = true; bt.innerText = lb[randN(lb.length)]; bt.focus(); }); })();
yihui/arith.js
6
简单的四则运算练习程序
JavaScript
yihui
Yihui Xie
rstudio swissre merck
R/build.R
R
blogdown::build_dir('static')
yihui/blogdown-static
9
A minimal example of building Rmd files under the static/ directory of a website based on blogdown and Hugo
HTML
yihui
Yihui Xie
rstudio swissre merck
static/slides/libs/remark-css/example.css
CSS
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz); @import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic); @import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700); body { font-family: 'Droid Serif', 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC', serif; } h1, h2, h3 { font-family: 'Yanone Kaffeesatz'; font-weight: normal; } a, a > code { color: rgb(249, 38, 114); text-decoration: none; } .footnote { position: absolute; bottom: 3em; padding-right: 4em; font-size: 90%; } .remark-code, .remark-inline-code { font-family: 'Source Code Pro', 'Lucida Console', Monaco, monospace; } .remark-code-line-highlighted { background-color: #ffff88; } .inverse { background-color: #272822; color: #d6d6d6; text-shadow: 0 0 20px #333; } .inverse h1, .inverse h2, .inverse h3 { color: #f3f3f3; line-height: 1.0em; } /* Two-column layout */ .left-column { color: #777; width: 20%; height: 92%; float: left; } .left-column h2:last-of-type, .left-column h3:last-child { color: #000; } .right-column { width: 75%; float: right; padding-top: 1em; } .pull-left { float: left; width: 47%; } .pull-right { float: right; width: 47%; } .pull-right ~ * { clear: both; } img, video, iframe { max-width: 100%; } blockquote { border-left: solid 5px lightgray; padding-left: 1em; }
yihui/blogdown-static
9
A minimal example of building Rmd files under the static/ directory of a website based on blogdown and Hugo
HTML
yihui
Yihui Xie
rstudio swissre merck
static/slides/xaringan.html
HTML
<!DOCTYPE html> <html> <head> <title>Presentation Ninja</title> <meta charset="utf-8"> <meta name="author" content="Yihui Xie" /> <link href="libs/remark-css/example.css" rel="stylesheet" /> </head> <body> <textarea id="source"> class: center, middle, inverse, title-slide # Presentation Ninja ## ⚔<br/>with xaringan (in blogdown) ### Yihui Xie ### 2017/07/28 --- background-image: url(https://upload.wikimedia.org/wikipedia/commons/b/be/Sharingan_triple.svg) ??? Image credit: [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Sharingan_triple.svg) --- class: center, middle # xaringan ### /ʃæ.'riŋ.ɡæn/ --- class: inverse, center, middle # Get Started --- # Hello World Install the **xaringan** package from [Github](https://github.com/yihui/xaringan): ```r devtools::install_github("yihui/xaringan") ``` -- You are recommended to use the [RStudio IDE](https://www.rstudio.com/products/rstudio/), but you do not have to. - Create a new R Markdown document from the menu `File -&gt; New File -&gt; R Markdown -&gt; From Template -&gt; Ninja Presentation`;&lt;sup&gt;1&lt;/sup&gt; -- - Click the `Knit` button to compile it; -- - or use the [RStudio Addin](https://rstudio.github.io/rstudioaddins/)&lt;sup&gt;2&lt;/sup&gt; "Infinite Moon Reader" to live preview the slides (every time you update and save the Rmd document, the slides will be automatically reloaded in RStudio Viewer. .footnote[ [1] 中文用户请看[这份教程](http://slides.yihui.name/xaringan/zh-CN.html) [2] See [#2](https://github.com/yihui/xaringan/issues/2) if you do not see the template or addin in RStudio. ] --- background-image: url(https://github.com/yihui/xaringan/releases/download/v0.0.2/karl-moustache.jpg) background-position: 50% 50% class: center, bottom, inverse # You only live once! --- class: center, middle # Thanks! Slides created via the R package [**xaringan**](https://github.com/yihui/xaringan). The chakra comes from [remark.js](https://remarkjs.com), [**knitr**](http://yihui.name/knitr), and [R Markdown](https://rmarkdown.rstudio.com). </textarea> <script src="https://remarkjs.com/downloads/remark-latest.min.js"></script> <script>var slideshow = remark.create({ "highlightStyle": "github", "countIncrementalSlides": false }); if (window.HTMLWidgets) slideshow.on('afterShowSlide', function (slide) {window.dispatchEvent(new Event('resize'));});</script> </body> </html>
yihui/blogdown-static
9
A minimal example of building Rmd files under the static/ directory of a website based on blogdown and Hugo
HTML
yihui
Yihui Xie
rstudio swissre merck
build.R
R
# TODO: use CRAN version of xfun (>= 0.26) install.packages('remotes') remotes::install_github('yihui/xfun') db = available.packages(type = 'source') all_pkgs = rownames(db) ver = paste(unlist(getRversion())[1:2], collapse = '.') # version x.y dir = file.path('bin/macosx/contrib', ver) # no openmp support cat('\nSHLIB_OPENMP_CFLAGS=\nSHLIB_OPENMP_CXXFLAGS=\n', file = '~/.R/Makevars', append = TRUE) # only build packages that needs compilation and don't have binaries on CRAN db2 = available.packages(type = 'binary') pkgs = setdiff(all_pkgs, rownames(db2)) pkgs = pkgs[db[pkgs, 'NeedsCompilation'] == 'yes'] pkgs = setdiff(pkgs, readLines('ignore')) # exclude pkgs that I'm unable to build # manually specify a subset of packages to be built if (file.exists('subset')) pkgs = intersect(pkgs, readLines('subset')) # extra packages that must be built pkgs = c(if (file.exists('extra')) readLines('extra'), if (FALSE) pkgs) # NOTE: originally we tried to build all packages that don't have binaries on # CRAN, but this made the project burdensome to maintain; now we only build # these 'extra' packages. If any volunteer wants to pick up the original # project, please feel free to let me know and I can transfer it to you. # set an env var to decide which subset of pkgs to build, e.g., "0, 0.5", "0.1, 8.7" if (!is.na(i <- Sys.getenv('CRAN_BUILD_SUBSET', NA))) { n = length(pkgs) i = as.numeric(strsplit(i, ',\\s*')[[1]]) * n i = seq(max(1, floor(i[1])), min(n, ceiling(i[2]))) pkgs = pkgs[i] } home = xfun::read_utf8('README.md') system('git checkout gh-pages') unlink(c('CNAME', 'src'), recursive = TRUE) writeLines(c( 'https://macos.rbind.org/* https://macos.rbind.io/:splat 301!', '/src/* https://cran.rstudio.com/src/:splat', '/bin/windows/* https://cran.rstudio.com/bin/windows/:splat' ), '_redirects') sysreqsdb = if (file.exists(sysdb <- 'bin/macosx/sysreqsdb.rds')) readRDS(sysdb) else list() # install brew dependencies that are not available in r-hub/sysreqsdb yet sysreqsdb2 = list( glpkAPI = 'glpk', Rglpk = 'glpk', rDEA = 'glpk', qtbase = 'qt', Rhpc = 'open-mpi', RDieHarder = 'dieharder', Rgnuplot = 'gnuplot', RQuantLib = 'quantlib', RcppMeCab = 'mecab', RGtk2 = c('gtk+', 'gobject-introspection'), RSclient = 'openssl', Rmpi = 'open-mpi', cairoDevice = c('gtk+', 'cairo'), rgl = c('freetype', 'freeglut'), rrd = 'rrdtool', libstableR = 'gsl' ) base_pkgs = xfun::base_pkgs() # query Homebrew dependencies for an R package and save them brew_dep = function(pkg) { if (pkg %in% base_pkgs) return() d = sysreqsdb[[pkg]] v = xfun::attr(d, 'Version') v2 = if (pkg %in% all_pkgs) db[pkg, 'Version'] else NA # return if dependency exists and package version hasn't changed if (!is.null(d) && identical(v, v2)) return(d) x = unique(c(xfun:::brew_dep(pkg), sysreqsdb2[[pkg]])) attr(x, 'Version') = v2 sysreqsdb[[pkg]] <<- x } for (i in unique(c(pkgs, .packages(TRUE), names(sysreqsdb)))) sysreqsdb[[i]] = brew_dep(i) # refresh the db for a random subset of all CRAN packages (can't do all because # querying dependencies is time-consuming) sample_max = function(x, n) { sample(x, min(n, length(x))) } # packages for which we haven't queried dependencies yet for (i in sample_max(setdiff(all_pkgs, names(sysreqsdb)), 5000)) { sysreqsdb[[i]] = brew_dep(i) } # remove packages that are no longer on CRAN # for (i in setdiff(names(sysreqsdb), all_pkgs)) sysreqsdb[[i]] = NULL brew_deps = function(pkgs) { unlist(lapply(unique(pkgs), brew_dep)) } install_deps = function(pkgs) { dep = brew_deps(c(pkgs, xfun:::pkg_dep(pkgs, db, recursive = TRUE), .packages(TRUE))) dep = setdiff(dep, c('TODO', 'pandoc-citeproc')) # not sure how `TODO` came in if (length(dep) == 0) return() dep = paste(unique(dep), collapse = ' ') if (dep == '') return() message('Installing Homebrew dependencies: ', dep) system(paste('brew install', dep)) } # R 4.0 changed the package path (no longer use el-capitan in the path) if (dir.exists(d4 <- 'bin/macosx/el-capitan/contrib')) { unlink(dir, recursive = TRUE) file.rename(d4, dirname(dir)) } # when a new version of R appears, move the old binary packages to the new dir if (!dir.exists(dir)) xfun::in_dir(dirname(dir), { if ((n <- length(vers <- list.files('.', '^\\d+[.]\\d+$'))) >= 1) { unlink(vers[seq_len(n - 1)], recursive = TRUE) file.rename(vers[n], ver) } }) dir.create(dir, recursive = TRUE, showWarnings = FALSE) # delete binaries that have become available on CRAN, or of multiple versions of # the same package if (!file.exists('subset')) { tgz = list.files(dir, '.+_.+[.]tgz$', full.names = TRUE) tgz_name = gsub('_.*', '', basename(tgz)) file.remove(tgz[!(tgz_name %in% pkgs) | duplicated(tgz_name, fromLast = TRUE)]) } xfun:::check_built(dir, dry_run = FALSE) install_extra = function(p) { install.packages(p, repos = c(paste0('file://', getwd()), getOption('repos')), type = 'mac.binary') } for (i in setdiff(xfun:::broken_packages(reinstall = FALSE), 'tcltk')) { remove.packages(i) install_extra(i) } # download source packages that have been updated on CRAN if (file.exists(pkg_file <- file.path(dir, 'PACKAGES'))) { info = read.dcf(pkg_file, c('Package', 'Version')) info = info[info[, 1] %in% all_pkgs, , drop = FALSE] # packages may be archived pkgs = setdiff(pkgs, info[as.numeric_version(db[info[, 1], 'Version']) <= info[, 2], 1]) } # pkgs = intersect(pkgs, all_pkgs) if (length(pkgs) == 0) q('no') pkg_all = c(all_pkgs, rownames(installed.packages())) for (pkg in pkgs) { if (pkg %in% all_pkgs) { # dependency not available on CRAN if (!all(xfun:::pkg_dep(pkg, db) %in% pkg_all)) next xfun:::download_tarball(pkg, db) } else { system2('git', c('clone', sprintf('https://github.com/cran/%s.git', pkg))) xfun::Rcmd(c('build', pkg)) unlink(pkg, recursive = TRUE) } } srcs = list.files('.', '.+[.]tar[.]gz$') pkgs = gsub('_.*$', '', srcs) names(pkgs) = srcs # for building RGtk2/cairoDevice Sys.setenv(PKG_CONFIG_PATH = paste( "/usr/local/lib/pkgconfig", "/usr/local/lib/pkgconfig/gtk+-2.0.pc", "/opt/X11/lib/pkgconfig", sep = ":" )) failed = NULL # build binary packages build_one = function(pkg) { # remove existing binary packages file.remove(list.files(dir, paste0('^', pkg, '_.+[.]tgz$'), full.names = TRUE)) # skip if already built if (length(list.files('.', paste0('^', pkg, '_.+[.]tgz$')))) return() for (p in intersect(pkgs, deps <- xfun:::pkg_dep(pkg, db))) build_one(pkgs[pkgs == p]) for (p in deps) { if (!xfun::loadable(p)) install_extra(p) } if (xfun::Rcmd(c('INSTALL', '--build', names(pkg))) != 0) failed <<- c(failed, pkg) } t0 = Sys.time() install_deps(pkgs) # install all brew dependencies for R packages for (i in seq_along(pkgs)) { message('Building ', pkgs[i], ' (', i, '/', length(pkgs), ')') build_one(pkgs[i]) # give up the current job to avoid timeout on Github Action this time; we can # continue the rest next time if (difftime(Sys.time(), t0, units = 'mins') > 300) break } if (length(failed)) warning('Failed to build packages: ', paste(failed, collapse = ' ')) file.copy(list.files('.', '.+[.]tgz$', full.names = TRUE), dir, overwrite = TRUE) unlink(c('*.tar.gz', '*.tgz', '_AUTOBREW_BUILD', 'binaries'), recursive = TRUE) # render the homepage index.html local({ x = home x[1] = paste0(x[1], '\n\n### Yihui Xie\n\n### ', Sys.Date(), '\n') # insert successfully built package names after a code block p = list.files(dir, r <- '_[-0-9.]+[.]tgz$') p = gsub(r, '', p) i = grep('rownames\\(available.packages', x)[1] x = append(x, c( '\n```', capture.output(print(p)), '```\n' ), which(x[i:length(x)] == '```')[1] + 1 + i) xfun::write_utf8(x, 'index.Rmd') xfun::pkg_load2('knitr') knitr::rocco('index.Rmd') }) unlink(c('PACKAGES*', 'index.md', 'index.Rmd')) tools::write_PACKAGES(dir, type = 'mac.binary') saveRDS(sysreqsdb, sysdb) system2('ls', c('-lh', dir)) system('du -sh .')
yihui/homebrew-cran-extra
23
A "CRAN extras" repository of some binary R packages for the Homebrew (cask) version of base R on macOS
R
yihui
Yihui Xie
rstudio swissre merck
exampleSite/layouts/partials/disqus.html
HTML
{{ if and (not (eq .Site.Config.Services.Disqus.Shortname "")) (not .Params.disable_comments) }} <section class="comments"> <div id="disqus_thread"></div> <script> var disqus_config = function () { {{ with .Site.Params.disqusURL }} this.page.url = "{{ . }}" + {{ if eq $.Type "404" }} "/404.html" {{ else }} location.pathname{{ end }}; {{ end }} }; (function() { var inIFrame = function() { var iframe = true; try { iframe = window.self !== window.top; } catch (e) {} return iframe; }; if (inIFrame()) return; var disqus_js = '//{{ .Site.Config.Services.Disqus.Shortname }}.disqus.com/embed.js'; var d = document, s = d.createElement('script'); s.src = disqus_js; s.async = true; s.setAttribute('data-timestamp', +new Date()); (d.head || d.body).appendChild(s); })(); </script> <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> </section> {{ end }}
yihui/hugo-ivy
297
A two-column Hugo theme ported from Ivy
HTML
yihui
Yihui Xie
rstudio swissre merck
exampleSite/layouts/partials/foot_custom.html
HTML
{{ if .Section }} <nav class="post-nav"> <span class="nav-prev">{{ with .PrevInSection }}&larr; <a href="{{ .RelPermalink }}">{{ .Title }}</a>{{ end }}</span> <span class="nav-next">{{ with .NextInSection }}<a href="{{ .RelPermalink }}">{{ .Title }}</a> &rarr;{{ end }}</span> </nav> {{ end }} {{ partial "disqus.html" . }} <script src="//cdn.jsdelivr.net/npm/@xiee/utils/js/math-code.js" defer></script> <script src="//mathjax.rstudio.com/latest/MathJax.js?config=TeX-MML-AM_CHTML" defer></script> <script src="//cdn.jsdelivr.net/npm/@xiee/utils/js/center-img.js" defer></script>
yihui/hugo-ivy
297
A two-column Hugo theme ported from Ivy
HTML
yihui
Yihui Xie
rstudio swissre merck
exampleSite/layouts/partials/head_custom.html
HTML
<link rel="stylesheet" href="{{ "/css/custom.css" | relURL }}" />
yihui/hugo-ivy
297
A two-column Hugo theme ported from Ivy
HTML
yihui
Yihui Xie
rstudio swissre merck
exampleSite/static/css/custom.css
CSS
.hljs { padding: 1em; }
yihui/hugo-ivy
297
A two-column Hugo theme ported from Ivy
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/404.html
HTML
{{ partial "header.html" . }} 404 NOT FOUND {{ partial "footer.html" . }}
yihui/hugo-ivy
297
A two-column Hugo theme ported from Ivy
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/_default/list.html
HTML
{{ partial "header.html" . }} {{ .Content }} <ul> {{ range (where (cond .IsHome .Site.RegularPages .Pages) "Section" "!=" "") }} <li> <span class="date">{{ .Date.Format "2006/01/02" }}</span> <a href="{{ .RelPermalink }}">{{ .Title }}</a> </li> {{ end }} </ul> {{ partial "footer.html" . }}
yihui/hugo-ivy
297
A two-column Hugo theme ported from Ivy
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/_default/single.html
HTML
{{ partial "header.html" . }} {{ if .Params.show_toc }} {{ .TableOfContents }} {{ end }} {{ if (and (eq (getenv "HUGO_BLOGDOWN_POST_RELREF") "") (and (and .Params.date (lt (now.AddDate 0 0 ($.Site.Params.holdDays | default -90)) .Date)) (in (string .Content) "<!--# ON_HOLD -->"))) }} {{ (index (split .Content "<!--# ON_HOLD -->") 0) | safeHTML }} {{ else }} {{ .Content }} {{ end }} {{ partial "footer.html" . }}
yihui/hugo-ivy
297
A two-column Hugo theme ported from Ivy
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/_default/terms.html
HTML
{{ partial "header.html" . }} <ul class="terms"> {{ range $key, $value := .Data.Terms }} <li> <a href="{{ (print "/" $.Data.Plural "/" $key | urlize) | relURL }}"> {{ $key }} </a> ({{ len $value }}) </li> {{ end }} </ul> {{ partial "footer.html" . }}
yihui/hugo-ivy
297
A two-column Hugo theme ported from Ivy
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/partials/footer.html
HTML
<footer> {{ partial "foot_custom.html" . }} {{ partial "footer_highlightjs" . }} {{ with .Site.Params.footer }} <hr> <div class="copyright">{{ replace . "{Year}" now.Year | markdownify }}</div> {{ end }} </footer> </article> {{ template "_internal/google_analytics.html" . }} </body> </html>
yihui/hugo-ivy
297
A two-column Hugo theme ported from Ivy
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/partials/footer_highlightjs.html
HTML
{{ if and (not .Params.disable_highlight) (in (string .Content) "</pre>") }} {{ $highVer := .Site.Params.highlightjsVersion }} {{ if (not (eq $highVer "")) }} {{ $highJS := (print "//cdn.jsdelivr.net/combine/gh/highlightjs/cdn-release@" $highVer "/build/highlight.min.js") }} {{ range (union .Site.Params.highlightjsLang .Params.highlightjsLang) }} {{ $highJS := print $highJS ",gh/highlightjs/cdn-release@" $highVer "/build/languages/" . ".min.js" }} {{ end }} {{ $highJS := print $highJS ",npm/@xiee/utils/js/load-highlight.js" }} <script src="{{ $highJS }}" defer></script> {{ end }} {{ end }}
yihui/hugo-ivy
297
A two-column Hugo theme ported from Ivy
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/partials/head_highlightjs.html
HTML
{{ if and (not .Params.disable_highlight) (in (string .Content) "</pre>") }} {{ $highTheme := .Site.Params.highlightjsTheme }} {{ with .Site.Params.highlightjsVersion }} <link rel="stylesheet" href="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@{{ . }}/build/styles/{{ $highTheme }}.min.css"> {{ end }} {{ end }}
yihui/hugo-ivy
297
A two-column Hugo theme ported from Ivy
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/partials/header.html
HTML
<!DOCTYPE html> {{ partial "html_open.html" . }} <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> {{ if eq .RelPermalink "/" }} <title>{{ .Site.Title }}</title> <meta property="og:title" content="{{ .Site.Title }}"> <meta property="og:type" content="website"> {{ else }} <title>{{ .Title }}{{ with .Params.subtitle }} - {{ . }} {{ end }} - {{ .Site.Title }}</title> <meta property="og:title" content="{{ .Title }} - {{ .Site.Title }}"> {{ end }} <meta name="twitter:card" content="summary"> {{ $summary := "" }} {{ with .Description }} {{ $summary = (markdownify .) }} {{ else }} {{ $summary = ((delimit (findRE "(<p.*?>(.|\n)*?</p>\\s*)+" .Content) "[&hellip;] ") | plainify | truncate (default 200 .Site.Params.summary_length) (default " &hellip;" .Site.Params.text.truncated)) }} {{ end }} {{ if eq .RelPermalink "/" }} <meta property="description" content="{{ .Site.Params.description }}"> {{ else }} {{ with $summary }} <meta property="description" content="{{ . }}"> <meta property="og:description" content="{{ . }}"> {{ end }} {{ end }} {{ $autoImage := false }} {{ range (findRE "<img src=\"https?://[^\"]+" .Content 1) }} {{ $autoImage = true }} <meta name="twitter:image" content="{{ replaceRE "<img src=\"" "" . | htmlUnescape }}"> {{ end }} {{ with .Site.Params.twitterImage }} {{ if not $autoImage }} <meta name="twitter:image" content="{{ absURL . }}"> {{ end }} {{ end }} {{ if .Keywords }} <meta property="keywords" content ="{{ delimit .Keywords ", " }}"> {{ end }} {{ with .OutputFormats.Get "RSS" }} <link href="{{ .RelPermalink }}" rel="alternate" type="application/rss+xml" title="{{ $.Site.Title }}" /> {{ end }} {{ partial "head_highlightjs" . }} <link rel="stylesheet" href="{{ "/css/style.css" | relURL }}" /> <link rel="stylesheet" href="{{ "/css/fonts.css" | relURL }}" /> {{ partial "head_custom.html" . }} </head> {{- $section := (replaceRE "^/([^/]+)/.*" "$1" .RelPermalink) -}} {{ $.Scratch.Set "section" $section }} <body class="{{ if .IsHome }}home{{ else }}{{ $section }}{{ end }}{{ with .Params.page_class }} {{ . }}{{ end }}"> <header class="masthead"> {{ partialCached "tagline.html" . $section }} {{ partial "menu.html" . }} </header> <article class="main"> <header class="title"> {{ partial "meta.html" . }} </header>
yihui/hugo-ivy
297
A two-column Hugo theme ported from Ivy
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/partials/html_open.html
HTML
<html lang="{{ .Site.LanguageCode }}">
yihui/hugo-ivy
297
A two-column Hugo theme ported from Ivy
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/partials/menu.html
HTML
<nav class="menu"> <input id="menu-check" type="checkbox" hidden/> <label id="menu-label" for="menu-check" class="unselectable" hidden> <span class="icon close-icon">✕</span> <span class="icon open-icon">☰</span> <span class="text">Menu</span> </label> <ul> {{ $currentPage := . }} {{ range (default .Site.Menus.main (index .Site.Menus ($.Scratch.Get "section"))) }} <li{{ if eq .URL $currentPage.RelPermalink }} class="active"{{ end }}><a href="{{ .URL }}">{{ .Name }}</a></li> {{ end }} {{ partial "menu_extra.html" . }} </ul> </nav>
yihui/hugo-ivy
297
A two-column Hugo theme ported from Ivy
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/partials/meta.html
HTML
{{ if not .IsHome }} <h1>{{ .Title }}</h1> {{ with .Params.subtitle }}<h2 class="subtitle">{{ . }}</h2>{{ end }} {{ $author := false }} {{ if .IsPage }} <h3>{{ with or (or .Params.author (index (or .Site.Params.author dict) .Section)) "" }} {{ $author = . }} {{ . }} {{ end }} {{ $date := "" }} {{ if .Params.date }} {{ $date = .Date.Format "2006-01-02" }} {{ else }} {{ with .Lastmod }} {{ $date = .Format "2006-01-02" }} {{ end }} {{ end }} {{ with $date }} {{ if $author }} / {{ end }} {{ . }} {{ end }}</h3> {{ end }} <hr> {{ end }}
yihui/hugo-ivy
297
A two-column Hugo theme ported from Ivy
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/partials/tagline.html
HTML
<h1><a href="{{ relURL "/" }}">{{ .Site.Title }}</a></h1> {{ with .Site.Params.Description }}<p class="tagline">{{ . }}</p>{{ end }}
yihui/hugo-ivy
297
A two-column Hugo theme ported from Ivy
HTML
yihui
Yihui Xie
rstudio swissre merck
static/css/fonts.css
CSS
body { font-family: Optima, 'Lucida Sans', Calibri, Candara, Arial, 'source-han-serif-sc', 'Source Han Serif SC', 'Source Han Serif CN', 'Source Han Serif TC', 'Source Han Serif TW', 'Source Han Serif', 'Noto Serif CJK SC', 'Songti SC', 'Microsoft YaHei', sans-serif; } code { font-family: "Lucida Console", 'Andale Mono', 'STKaiti', 'KaiTi', 'SimKai', monospace; } pre code { font-family: Consolas, "Lucida Console", Monaco, 'STKaiti', 'KaiTi', 'SimKai', monospace; }
yihui/hugo-ivy
297
A two-column Hugo theme ported from Ivy
HTML
yihui
Yihui Xie
rstudio swissre merck
static/css/style.css
CSS
/* Micro Reset */ html { font-size: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; box-sizing: border-box; } *, *:before, *:after { box-sizing: inherit; } body { margin: 0; padding: 0; } button, input, select, textarea, label { margin: 0; padding: 0; font-family: inherit; font-size: inherit; } img { max-width: 100%; } /* Typography */ body { line-height: 1.75; } .title * { font-weight: 500; } h1, h2 { padding: 0; margin: 60px 0 30px; line-height: 1.25; text-align: center; } h1 { font-size: 32px; } h2 { font-size: 24px; } blockquote { margin: 1em 0; padding: 0 2em; border-left: 3px solid #ddd; } /* Code */ pre, code { font-size: .9em; } pre code { display: block; border: 1px solid #ddd; box-shadow: 5px 5px 5px #eee; padding: 1em; overflow-x: auto; line-height: 1.75; } code { background: #f9f9f9; } pre code { background: none; } /* Lists */ ul, ol { padding: 0 0 0 20px; } li { margin: 4px 0; padding: 0; } /* Links */ a { color: black; text-decoration: none; padding-bottom: 2px; border-bottom: 1px solid; } a:hover { } sup a { border-bottom: none; } /* Miscellanea */ hr { display: block; height: 1px; border: 0; border-top: 1px solid; margin: 50px auto; padding: 0; max-width: 300px; } .copyright { text-align: center; } .post-nav { display: flex; justify-content: space-between; font-weight: bold; } .nav-next { margin-left: 1em; text-align: right; } .nav-prev { margin-right: 1em; } .comments { margin-top: 20px; } /* Layout */ body { width: 960px; margin: 0 auto; padding: 30px 0; } .masthead { width: 260px; padding: 20px 50px 20px 10px; float: left; } .main { width: 700px; padding: 32px 10px 20px 50px; margin-left: 260px; border-left: 3px solid black; min-height: calc(100vh - 60px); } /* Masthead */ .masthead h1 { margin-top: 0; margin-bottom: 34px; padding: 0; text-align: right; font-size: 46px; line-height: 58px; } .masthead h1 a { border-bottom: none; } .masthead .tagline { font-style: italic; text-align: right; } .masthead .menu { margin-right: 20px; direction: rtl; } .masthead .menu a { direction: ltr; } .masthead .menu ul ul { list-style: none; margin-left: 10px; margin-right: 10px; } .masthead .menu li li::before { content: "•\00a\000a0\00a0" } #menu-check { display: none; } #menu-label { display: none; } /* Main */ .main .title h1 { margin-top: 0; margin-bottom: 40px; } .title h3 { text-align: center; } .subtitle { color: #666; } /* Footnotes */ .footnotes { font-size: .9em; } /* Tables */ table { margin: auto; border-top: 1px solid #666; border-bottom: 1px solid #666; } table thead th { border-bottom: 1px solid #666; } th, td { padding: 5px; } thead, tfoot, tr:nth-child(even) { background: #f8f8f8; } /** * Utility Styles */ .unselectable { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } /** * ------------------------------------------------------------------------- * Media Queries * ------------------------------------------------------------------------- * * The @viewport tag does the same thing as * * <meta name="viewport" content="width=device-width"> * * but in the future W3C standard way. The -ms- prefix is required for * IE10+ to render responsive styling in Windows 8 "snapped" views; * IE10+ does not honour the meta tag. */ @-ms-viewport { width: device-width; } @viewport { width: device-width; } /* Tablet screens and smaller */ @media screen and (max-width: 960px) { body { width: auto; max-width: 700px; } .masthead { width: auto; float: none; padding: 20px 0 60px; text-align: center; margin-left: 10px; margin-right: 10px; border-bottom: 3px solid black; } .main { width: auto; padding: 40px 10px; margin-left: 0; border-left: none; min-height: auto; } .masthead h1 { text-align: center; } .masthead .tagline { text-align: center; } .masthead .menu { direction: ltr; max-width: 300px; margin-left: auto; margin-right: auto; } .masthead .menu ul { text-align: left; margin: 0; padding: 0; } .masthead .menu ul ul { margin: 0; } .masthead .menu li { border-bottom: 1px solid; list-style: none; margin: 0; padding: 0; } .masthead .menu li:first-child { border-top: 1px solid; } .masthead .menu li li:last-child { border-bottom: none; } .masthead .menu a { display: block; padding: 15px 20px; border-bottom: none; } .masthead .menu li li a { padding-left: 30px; } .masthead .menu li li::before { content: none; } .masthead .menu li li a::before { content: "•\00a0\00a0\00a0"; } #menu-label { display: inline-block; padding: 0 20px; height: 50px; border: 1px solid; cursor: pointer; line-height: 50px; color: #333; font-size: 20px; margin-top: 10px; } #menu-label:hover, #menu-label:focus { border: 1px solid #888; } #menu-label .icon { padding-right: 8px; width: 30px; } #menu-check ~ label .close-icon { display: none; } #menu-check ~ label .open-icon { display: inline-block; } #menu-check:checked ~ label .close-icon { display: inline-block; } #menu-check:checked ~ label .open-icon { display: none; } #menu-check ~ ul { display: none; } #menu-check:checked ~ ul { display: block; margin-top: 50px; margin-bottom: 0; } } /* Landscape phone screens and smaller */ @media screen and (max-width: 720px) { } /* Portrait phone screens */ @media screen and (max-width: 480px) { body { font-size: 16px; } h1 { font-size: 28px; } h2 { font-size: 18px; } h3, h4, h5, h6 { font-size: 16px; } pre, code { font-size: 12px; } .masthead { padding-top: 0; } }
yihui/hugo-ivy
297
A two-column Hugo theme ported from Ivy
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/404.html
HTML
{{ partial "header.html" . }} <h1 class="title">404 NOT FOUND</h1> {{ partial "footer.html" . }}
yihui/hugo-paged
48
A Hugo theme with the feel of printed media (inspired by paged.js)
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/_partials/foot_custom.html
HTML
{{- if (in .Content "</dl>") -}} <script src="//cdn.jsdelivr.net/npm/@xiee/utils/js/dl-fieldset.min.js" defer></script> {{ end }} {{- $has_code := (in .Content "</code></pre>") -}} {{- $has_img := (in .Content `<img `) -}} {{- $has_toc := .Scratch.Get "has_toc" -}} {{- if $has_toc -}} <script src="//cdn.jsdelivr.net/npm/@xiee/utils/js/fix-toc.min.js" defer></script> {{ end }} {{- if or $has_img (in .Content "<p>* * *</p>") -}} <script src="//cdn.jsdelivr.net/npm/@xiee/utils/js/center-img.min.js" defer></script> {{ end }} {{- if $has_img -}} <script src="//cdn.jsdelivr.net/npm/@xiee/utils/js/alt-title.min.js" defer></script> {{ end }} {{- if not (default (not $has_code) .Params.disable_highlight) -}} <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/@xiee/utils/css/prism-xcode.min.css"> <script src="//cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-core.min.js" defer></script> <script src="//cdn.jsdelivr.net/npm/prismjs@1.29.0/plugins/autoloader/prism-autoloader.min.js" defer></script> {{ end }} {{- if not (default (not (in .Content "<code>$")) .Params.disable_math) -}} <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/katex/dist/katex.min.css"> <script src="//cdn.jsdelivr.net/npm/@xiee/utils/js/math-code.min.js" defer></script> <script src="//cdn.jsdelivr.net/combine/npm/katex/dist/katex.min.js,npm/katex/dist/contrib/auto-render.min.js,npm/@xiee/utils/js/render-katex.js" defer></script> {{ end }} {{- if $has_code -}} <script src="//cdn.jsdelivr.net/npm/@xiee/utils/js/copy-button.min.js" defer></script> <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/@xiee/utils/css/copy-button.min.css"> {{ end }} {{- if (findRE `<p>(—|―|---|&mdash;)` .Content | len) -}} <script src="//cdn.jsdelivr.net/npm/@xiee/utils/js/right-quote.min.js" defer></script> {{ end }} {{- if or (in .Content "</kbd>") (in (replace .Content "</code></pre>" "") "</code>") -}} <script src="//cdn.jsdelivr.net/npm/@xiee/utils/js/key-buttons.min.js" defer></script> <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/@xiee/utils/css/key-buttons.min.css"> {{ end }} {{- if (in .Content `class="footnotes"`) -}} <script src="//cdn.jsdelivr.net/npm/@xiee/utils/js/fix-footnote.min.js" defer></script> {{ end }} {{- if (findRE `<h[1-6] ` .Content | len) -}} <script src="//cdn.jsdelivr.net/npm/@xiee/utils/js/heading-anchor.min.js" defer></script> {{ end }} {{- if (findRE `<a href="https?://` .Content | len) -}} <script src="//cdn.jsdelivr.net/npm/@xiee/utils/js/external-link.min.js" defer></script> {{ end }} {{- if (in .Content "</ol>") -}} <script src="//cdn.jsdelivr.net/npm/@xiee/utils/js/ol-id.min.js" defer></script> {{ end }} {{- if or $has_toc $has_code (in .Content "</table>") -}} <script src="//cdn.jsdelivr.net/npm/@xiee/utils/js/fullwidth.min.js" defer></script> {{ end }} {{- partial "foot_extra.html" . -}}
yihui/hugo-paged
48
A Hugo theme with the feel of printed media (inspired by paged.js)
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/_partials/footer.html
HTML
<footer class="small"> {{ partial "foot_custom.html" . }} {{ if .Site.Params.footer }} {{ if not $.IsHome }} <hr/> {{ end }} <p class="nav-bottom"> <span>{{ replace .Site.Params.footer "{Year}" now.Year | markdownify }}</span> <span class="menu-bottom">{{ partial "menu_extra.html" . }}</span> </p> {{ end }} </footer> </body> </html>
yihui/hugo-paged
48
A Hugo theme with the feel of printed media (inspired by paged.js)
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/_partials/head_custom.html
HTML
<link rel="stylesheet" href="https://indestructibletype.com/fonts/Jost.css">
yihui/hugo-paged
48
A Hugo theme with the feel of printed media (inspired by paged.js)
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/_partials/header.html
HTML
<!DOCTYPE html> {{ partial "html_open.html" . }} <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> {{ if eq .RelPermalink "/" }} <title>{{ .Site.Title }}</title> <meta property="og:title" content="{{ .Site.Title }}"> <meta property="og:type" content="website"> {{ else }} <title>{{ .Title }}{{ with .Params.subtitle }} - {{ . }} {{ end }} - {{ .Site.Title }}</title> <meta property="og:title" content="{{ .Title }} - {{ .Site.Title }}"> {{ end }} {{ if eq .RelPermalink "/" }} <meta name="description" content="{{ .Site.Params.description }}"> {{ else }} {{ with (trim (partial "summary.html" .) "\n ") }} <meta name="description" content="{{- . -}}"> {{ end }} {{ end }} {{ with .Keywords }} <meta property="keywords" content ="{{ delimit . ", " }}"> {{ end }} {{ with .OutputFormats.Get "RSS" }} <link href="{{ .RelPermalink }}" rel="alternate" type="application/rss+xml" title="{{ $.Site.Title }}"> {{ end }} {{ range (slice "style" "fonts" "custom") }} <link rel="stylesheet" href="{{ printf "css/%s.css" . | relURL }}"> {{ end }} {{ partial "head_custom.html" . }} </head> {{ $section := (replaceRE "^/([^/]+)/.*" "$1" .RelPermalink) }} {{ if eq $section "/" }}{{ $section = "" }}{{ end }} {{ $.Scratch.Set "section" $section }} {{ $class := complement (slice nil "") (slice (cond .IsPage "single" "") $section .Params.page_class (cond .IsHome "" ($.Scratch.Get "lang")) (cond (in .Content `<div class="footnotes"`) "has-sidenotes" "")) }} {{ if len $class }}<body class="{{ delimit (uniq $class) " " }}">{{ else }}<body>{{ end }} <div class="crop-h"></div><div class="crop-v"></div><div class="crop-c"></div> <nav class="nav-top small"> <div class="logo"> {{ with default .Site.Params.logo.en (index .Site.Params.logo $section) }} <a href="{{ relURL .url }}"> {{ if .img }} <img src="{{ relURL .img }}" alt="{{ .alt }}" /> {{ else }} {{ .alt }} {{ end }} </a> {{ end }} </div> <div class="menu"> {{- $active := "" -}} {{- $menu := (default .Site.Menus.main (index .Site.Menus $section)) -}} {{- range $menu -}} {{- if and (hasPrefix $.Page.RelPermalink (relURL .URL)) (gt (len .URL) (len $active)) -}} {{- $active = .URL -}} {{- end -}} {{- end -}} {{ range $menu }} {{- $mclass := or .Params.class slice -}} {{- if eq $active .URL -}} {{- $mclass = append (slice "active") $mclass -}} {{- end -}} {{- $mclass = delimit $mclass " " -}} <span{{ with $mclass }} class="{{ . }}"{{ end }}><a href="{{ relURL .URL }}">{{ .Name }}</a></span> {{ end }} </div> </nav>
yihui/hugo-paged
48
A Hugo theme with the feel of printed media (inspired by paged.js)
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/_partials/html_open.html
HTML
<html lang="{{ .Site.LanguageCode }}">
yihui/hugo-paged
48
A Hugo theme with the feel of printed media (inspired by paged.js)
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/_partials/menu_extra.html
HTML
{{ if not .IsHome }} {{ markdownify "[Categories](/categories/) [Tags](/tags/)" }} {{ with .Section }} <a href="{{ relURL . }}/index.xml" type="application/rss+xml" title="RSS feed">Subscribe</a> {{ end }} <a href="#">Back to Top</a> {{ end }}
yihui/hugo-paged
48
A Hugo theme with the feel of printed media (inspired by paged.js)
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/_partials/meta.html
HTML
{{ if .IsPage }} {{ with or (or .Params.author (index (or .Site.Params.author dict) (or ($.Scratch.Get "lang") .Section))) "" }} <span class="author">{{ . }}</span> {{ end }} {{ $date := "" }} {{ if .Params.date }} {{ $date = .Date.Format "2006-01-02" }} {{ else }} {{ with .Lastmod }} {{ $date = .Format "2006-01-02" }} {{ end }} {{ end }} {{ with $date }} <span class="date">{{ . }}</span> {{ end }} {{ end }}
yihui/hugo-paged
48
A Hugo theme with the feel of printed media (inspired by paged.js)
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/_partials/post_nav.html
HTML
{{ if .Section }} <nav class="post-nav fullwidth"> <span>{{ with .NextInSection }}&larr; <a href="{{ .RelPermalink }}">{{ .Title | markdownify }}</a>{{ end }}</span> <span>{{ with .PrevInSection }}<a href="{{ .RelPermalink }}">{{ .Title | markdownify }}</a> &rarr;{{ end }}</span> </nav> {{ end }}
yihui/hugo-paged
48
A Hugo theme with the feel of printed media (inspired by paged.js)
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/_partials/summary.html
HTML
{{ $summary := "" }} {{ if .Description }} {{ $summary = (markdownify .Description) }} {{ else }} {{ $summary = ((delimit (findRE "(?s)(<p.*?>.*?</p>)" .Content) "[&hellip;] ") | plainify | truncate (default 200 $.Site.Params.summary_length) (default " &hellip;" $.Site.Params.text.truncated ) | replaceRE "&amp;" "&" | safeHTML) }} {{ end }} {{ $summary }}
yihui/hugo-paged
48
A Hugo theme with the feel of printed media (inspired by paged.js)
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/_partials/toc-list.html
HTML
{{ $toc := partial "toc.html" . }} {{ replace $toc `<a href="#` (print "<a href=\"" .RelPermalink "#") | replaceRE "(?s)<nav ?.*?>|</nav>" "" | replaceRE "^\\s*<ul>" `<ul class="toc-list">` | safeHTML }}
yihui/hugo-paged
48
A Hugo theme with the feel of printed media (inspired by paged.js)
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/_partials/toc.html
HTML
{{ replaceRE `(?s)(<nav [^>]+>)\s*<ul>\s*<li>(\s*<ul>.+?</ul>)\s*</li>\s*</ul>(\s*</nav>)` `$1$2$3` .TableOfContents | safeHTML }}
yihui/hugo-paged
48
A Hugo theme with the feel of printed media (inspired by paged.js)
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/baseof.list.html
HTML
{{ partial "header.html" . }} {{if .IsHome }} <div class="home"> {{ .Content }} </div> {{ else }} <h1 class="title">{{ .Title | markdownify }}{{ if eq .Kind "term" }}<span class="small subtitle"> | <a href="{{ urlize .Type | relURL }}/">{{ .Type }}</a></span>{{ end }}</h1> {{ with .Params.subtitle }}<h2 class="subtitle">{{ . | markdownify }}</h2>{{ end }} <div class="main{{ if not .Content }} archive{{ end }}"> {{ .Content }} {{ block "page-list" . }} {{ range .RegularPages }} <h2 class="toc-line"><a href="{{ .RelPermalink }}">{{ .Title | markdownify }}</a><span class="dots"></span><span class="page-num small"></span></h2> <div class="meta-line small"> {{ partial "meta.html" . }} </div> {{ block "summary" . }} {{ end }} {{ end }} {{ end }} {{ partial "main_extra.html" . }} </div> {{ end }} {{ partial "footer.html" . }}
yihui/hugo-paged
48
A Hugo theme with the feel of printed media (inspired by paged.js)
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/blog/list.html
HTML
{{ define "summary" }} <blockquote>{{ partial "summary.html" . }}</blockquote> {{ end }}
yihui/hugo-paged
48
A Hugo theme with the feel of printed media (inspired by paged.js)
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/docs/list.html
HTML
{{ define "summary" }} {{ partial "toc-list.html" . }} {{ end }}
yihui/hugo-paged
48
A Hugo theme with the feel of printed media (inspired by paged.js)
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/list.html
HTML
{{ define "summary" }} {{ end }}
yihui/hugo-paged
48
A Hugo theme with the feel of printed media (inspired by paged.js)
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/single.html
HTML
{{ partial "header.html" . }} <div class="article-meta"> <h1 class="title">{{ .Title | markdownify }}</h1> {{ with .Params.subtitle }}<h2 class="subtitle">{{ . | markdownify }}</h2>{{ end }} <h3 class="meta-line"> <span>{{ partial "meta.html" . }}</span> <span class="term"> {{ with .Params.categories }} {{ range first 1 . }} {<a href="{{ relURL (print "categories/" . "/" | urlize) }}" class="term-cat">{{ . }}</a>} {{ end }} {{ end }} {{ with .Params.tags }} {{ $len := sub (len .) 1 }} {{ range $i, $v := . }} <a href="{{ relURL (print "tags/" $v "/" | urlize) }}" class="term-tag">{{ if eq $i 0 }}[{{ end }}{{ $v }}{{ if lt $i $len }},{{ else }}]{{ end }}</a> {{ end }} {{ end }} {{ partial "term_extra.html" . }} </span> </h3> </div> <div class="main"> {{ $toc := partial "toc.html" . }} {{ $toc_len := strings.Count `<li><a` $toc }} {{ if (default (ge $toc_len (default .Site.Params.toc_threshold 3)) .Params.show_toc) }} {{ .Scratch.Set "has_toc" true }} {{ if (default (ge $toc_len (default .Site.Params.toc_twocolumn 16)) .Params.toc_twocolumn) }} {{ replace $toc `<nav ` `<nav class="fullwidth twocolumn" ` | safeHTML }} {{ else }} {{ $toc }} {{ end }} {{ end }} {{ .Content }} {{ partial "post_nav.html" . }} {{ partial "main_extra.html" . }} </div> {{ partial "footer.html" . }}
yihui/hugo-paged
48
A Hugo theme with the feel of printed media (inspired by paged.js)
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/taxonomy.html
HTML
{{ partial "header.html" . }} <main class="main fullwidth"> <h1 class="title">{{ .Title }}</h1> <ul class="terms"> {{ range .Data.Terms }} <li> <a href="{{ .Page.RelPermalink }}">{{ .Page.LinkTitle }}</a> ({{ .Count }}) </li> {{ end }} </ul> </main> {{ partial "footer.html" . }}
yihui/hugo-paged
48
A Hugo theme with the feel of printed media (inspired by paged.js)
HTML
yihui
Yihui Xie
rstudio swissre merck
static/css/fonts.css
CSS
@font-face { font-family: 'Linden Hill'; font-style: normal; src: url('https://cdn.jsdelivr.net/gh/theleagueof/linden-hill/webfonts/LindenHill-webfont.woff') format('woff'); } @font-face { font-family: 'Linden Hill'; font-style: italic; src: url('https://cdn.jsdelivr.net/gh/theleagueof/linden-hill/webfonts/LindenHill-Italic-webfont.woff') format('woff'); } body { font-family: 'Linden Hill', Palatino, serif; } code { font-family: "Lucida Console", Monaco, monospace; font-size: 85%; } .menu, .meta-line, footer { font-family: Jost, Optima, Candara, sans-serif; }
yihui/hugo-paged
48
A Hugo theme with the feel of printed media (inspired by paged.js)
HTML
yihui
Yihui Xie
rstudio swissre merck
static/css/style.css
CSS
:root { --body-width: 992px; --text-width: 620px; --bg-body: white; --bg-block: #f9f9f9; --border-color: #ddd; --box-shadow: 5px 5px 5px #eee; } * { box-sizing: border-box; } body { max-width: var(--body-width); min-height: calc(100vh - 3em); background-color: var(--bg-body); margin: auto; padding: 1em; line-height: 1.5; position: relative; display: flex; flex-direction: column; counter-reset: pageNumber; } /* header and footer areas */ .nav-top, .single .meta-line, .nav-bottom, .post-nav { display: flex; justify-content: space-between; } .home + footer > .nav-bottom { display: block; } .nav-top { margin-bottom: 1em; border-bottom: 1px solid; } .logo { font-weight: bold; margin-top: .5rem; img { display: none; max-height: 4rem; position: absolute; top: 2em; } } .menu { text-transform: uppercase; span { display: inline-block; margin: .5rem 0 0 .5em; } .active { border-bottom: 5px solid; margin-bottom: -5px; } .optional { display: none; } } footer { text-align: center; margin-top: 2rem; } .menu-bottom a + a::before { content: " · "; } /* code */ pre code { display: block; padding: 1em; overflow-x: auto; &:not([class]) { background: none; } } pre code, img[src$="#border"] { border: 1px solid var(--border-color); box-shadow: var(--box-shadow); } code { hyphens: none; } pre code, pre code:hover { white-space: pre-wrap; word-break: break-all; } /* misc elements */ .main, .home { hyphens: auto; flex-grow: 1; } a { text-decoration: none; border-bottom: 1px dashed; color: initial; } @media (hover: hover) and (pointer: fine) { :not(.logo) > a:hover { position: relative; inset: 1px 0 0 1px; } } nav a, footer a, .archive a, sup a { border-bottom: none; } .anchor { &:not(:hover > *) { display: none; } & > a::before { content: "#"; } } .single .main { h2 { border-bottom: 1px solid var(--border-color); } h3 { font-variant: small-caps; text-align: center; } } li { margin: 4px 0; } hr { border-style: dashed; color: var(--border-color); } img, iframe, video { max-width: 100%; } #TableOfContents { background-color: var(--bg-block); padding: .5em; & > ul { margin: 0 auto; & > li > ul li { margin-right: 2em; } } } blockquote, .toc-list, .toc-list ul { border-left: 2px solid var(--border-color); padding-left: 1em; } .single blockquote { background: var(--bg-block); border-left-width: 5px; padding: 3px 1em 3px; } .post-nav { margin-top: 1rem; span { width: calc(50% - 1em); & + span { text-align: right; } } } table { min-width: 50%; margin: auto; border-top: 1px solid #aaa; border-bottom: 1px solid #aaa; thead th { border-bottom: 1px solid var(--border-color); } th, td { padding: 5px; } thead, tfoot, tr:nth-child(even), code { background: var(--bg-block); } } /* metadata */ .toc-line { display: flex; align-items: flex-end; } .dots { border-bottom: 2px dotted var(--border-color); margin: 0 .5em .5em; min-width: 10rem; flex-grow: 1; } .page-num { counter-increment: pageNumber; &::before { content: counter(pageNumber); } } .toc-list, .toc-list ul { list-style: none; margin-left: 1em; } .toc-line, .subtitle, .meta-line { font-weight: normal; } .author + .date::before { content: " / "; } h1.title, .toc-line > a { font-style: italic; } h1.title { margin-top: 1em; } h1.title::before { content: "❧"; font-style: normal; font-weight: normal; font-size: 6em; color: var(--border-color); opacity: .5; position: absolute; inset: -.15em 0; z-index: -1; } .small, .term, .footnotes, li li { font-size: .9em; } .footnotes > hr { max-width: 20em; margin-left: 0; } .terms, #TableOfContents > ul > li > ul { display: flex; flex-wrap: wrap; } .terms li, .term { margin-left: 2em; } .term-cat + .term-tag::before { content: " · "; } @media (min-width: 768px) { body { padding: 3.5em 2.5em; } .main { margin: auto; width: var(--text-width); } pre, table, .fullwidth { width: calc(min(100vw, var(--body-width)) - 5rem); margin-left: calc(50% + 2.5rem - min(100vw, var(--body-width)) / 2); } .crop-h, .crop-v, .crop-c { position: absolute; z-index: -1; } .crop-h { inset: 2em 0; border-top: 1px solid; border-bottom: 1px solid; } .crop-v { inset: 0 2em; border-left: 1px solid; border-right: 1px solid; } .crop-c { inset: 1em; border: 1.5em solid var(--bg-body); } .menu { margin-left: 2em; } .menu span { margin-left: 1em; } h1.title::before { font-size: 6em; inset: 0; } .logo img, .menu .optional { display: inline-block; } .twocolumn { columns: 2; } } @media only screen and (min-width: 992px) { body { min-height: calc(100vh - 5em); margin: 2em auto; } .home { padding: 0 2em; } h1.title { margin-top: 2em; &::before { font-size: 9em; inset: -.1em 0; } } pre code { white-space: pre; } } @media (prefers-color-scheme: dark) { :root { --bg-body: #dedad6; --bg-block: #d6d1cc; --border-color: #999; --box-shadow: 5px 5px 5px #ccc; } html, img, video, iframe { filter: invert(1); } }
yihui/hugo-paged
48
A Hugo theme with the feel of printed media (inspired by paged.js)
HTML
yihui
Yihui Xie
rstudio swissre merck
exampleSite/content/post/2020-11-10-r-markdown-demo/index.html
HTML
--- title: "R Markdown Demo" author: "Yihui Xie" date: '2020-11-10' slug: r-markdown-demo bibliography: packages.bib --- <div id="floats" class="section level2"> <h2>Floats</h2> <div id="full-width-figures" class="section level3"> <h3>Full-width figures</h3> <p>Use a fenced <code>Div</code> with the class <code>fullwidth</code>, e.g.,</p> <pre class="md"><code>::: {.fullwidth} Any Markdown content or code blocks here. ```{r, echo=FALSE, fig.dim=c(14, 4)} plot(sunspots) ``` :::</code></pre> <div class="fullwidth"> <div class="figure"><span style="display:block;" id="fig:sunspots"></span> <img src="{{< blogdown/postref >}}index_files/figure-html/sunspots-1.svg" alt="Monthly mean relative sunspot numbers from 1749 to 1983. Collected at Swiss Federal Observatory, Zurich until 1960, then Tokyo Astronomical Observatory." width="1344" /> <p class="caption"> Figure 1: Monthly mean relative sunspot numbers from 1749 to 1983. Collected at Swiss Federal Observatory, Zurich until 1960, then Tokyo Astronomical Observatory. </p> </div> </div> <p>If you add the class <code>fullscroll</code> to the <code>Div</code>, the figure will be scrollable, e.g.,</p> <pre class="md"><code>::: {.fullwidth .fullscroll} :::</code></pre> <div class="fullwidth fullscroll"> <div class="figure"><span style="display:block;" id="fig:scroll"></span> <img src="{{< blogdown/postref >}}index_files/figure-html/scroll-1.svg" alt="This is a super wide figure that you need to scroll to view it fully." width="2880" /> <p class="caption"> Figure 2: This is a super wide figure that you need to scroll to view it fully. </p> </div> </div> </div> <div id="embedded-figures" class="section level3"> <h3>Embedded figures</h3> <p>You can embed any elements (typically figures) that span into the page margin. Use a fenced <code>Div</code> with the class <code>embed-left</code> or <code>embed-right</code>, e.g.,</p> <div class="embed-right"> <div class="figure"><span style="display:block;" id="fig:embed-plot"></span> <img src="{{< blogdown/postref >}}index_files/figure-html/embed-plot-1.svg" alt="This is a figure embedded on the right." width="480" /> <p class="caption"> Figure 3: This is a figure embedded on the right. </p> </div> </div> <pre class="md"><code>::: {.embed-right} Here is a special figure. ```{r} plot(cars) ``` :::</code></pre> <p>If you want to embed a table, that will be okay, too. Really, you can embed anything.</p> <pre class="md"><code>::: {.embed-left} ```{r, echo=FALSE} knitr::kable(head(mtcars), caption = &#39;An example dataset.&#39;) ``` :::</code></pre> <div class="embed-left"> <table style="width:100%;"> <caption><span id="tab:unnamed-chunk-1">Table 1: </span>An example dataset.</caption> <colgroup> <col width="26%" /> <col width="7%" /> <col width="5%" /> <col width="7%" /> <col width="5%" /> <col width="7%" /> <col width="8%" /> <col width="8%" /> <col width="4%" /> <col width="4%" /> <col width="7%" /> <col width="7%" /> </colgroup> <thead> <tr class="header"> <th align="left"></th> <th align="right">mpg</th> <th align="right">cyl</th> <th align="right">disp</th> <th align="right">hp</th> <th align="right">drat</th> <th align="right">wt</th> <th align="right">qsec</th> <th align="right">vs</th> <th align="right">am</th> <th align="right">gear</th> <th align="right">carb</th> </tr> </thead> <tbody> <tr class="odd"> <td align="left">Mazda RX4</td> <td align="right">21.0</td> <td align="right">6</td> <td align="right">160</td> <td align="right">110</td> <td align="right">3.90</td> <td align="right">2.620</td> <td align="right">16.46</td> <td align="right">0</td> <td align="right">1</td> <td align="right">4</td> <td align="right">4</td> </tr> <tr class="even"> <td align="left">Mazda RX4 Wag</td> <td align="right">21.0</td> <td align="right">6</td> <td align="right">160</td> <td align="right">110</td> <td align="right">3.90</td> <td align="right">2.875</td> <td align="right">17.02</td> <td align="right">0</td> <td align="right">1</td> <td align="right">4</td> <td align="right">4</td> </tr> <tr class="odd"> <td align="left">Datsun 710</td> <td align="right">22.8</td> <td align="right">4</td> <td align="right">108</td> <td align="right">93</td> <td align="right">3.85</td> <td align="right">2.320</td> <td align="right">18.61</td> <td align="right">1</td> <td align="right">1</td> <td align="right">4</td> <td align="right">1</td> </tr> <tr class="even"> <td align="left">Hornet 4 Drive</td> <td align="right">21.4</td> <td align="right">6</td> <td align="right">258</td> <td align="right">110</td> <td align="right">3.08</td> <td align="right">3.215</td> <td align="right">19.44</td> <td align="right">1</td> <td align="right">0</td> <td align="right">3</td> <td align="right">1</td> </tr> <tr class="odd"> <td align="left">Hornet Sportabout</td> <td align="right">18.7</td> <td align="right">8</td> <td align="right">360</td> <td align="right">175</td> <td align="right">3.15</td> <td align="right">3.440</td> <td align="right">17.02</td> <td align="right">0</td> <td align="right">0</td> <td align="right">3</td> <td align="right">2</td> </tr> <tr class="even"> <td align="left">Valiant</td> <td align="right">18.1</td> <td align="right">6</td> <td align="right">225</td> <td align="right">105</td> <td align="right">2.76</td> <td align="right">3.460</td> <td align="right">20.22</td> <td align="right">1</td> <td align="right">0</td> <td align="right">3</td> <td align="right">1</td> </tr> </tbody> </table> </div> <p>Now I have generate some text to fill the space on the right: hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer hold my beer.</p> </div> </div> <div id="text-elements" class="section level2"> <h2>Text elements</h2> <div id="table-of-contents" class="section level3"> <h3>Table of contents</h3> <p>TOC should be automatically generated unless it is disabled via <code>features: [-toc]</code> in YAML. To define the TOC title, use the <code>toc-title</code> field in YAML.</p> </div> <div id="section-numbers" class="section level3"> <h3>Section numbers</h3> <p>Sections should be automatically numbered unless Pandoc has already numbered them,<a href="#fn1" class="footnote-ref" id="fnref1"><sup>1</sup></a> or the feature is disabled via <code>features: [-number_sections]</code>.</p> </div> <div id="footnotes" class="section level3"> <h3>Footnotes</h3> <p>Footnotes should be automatically moved to the right margin,<a href="#fn2" class="footnote-ref" id="fnref2"><sup>2</sup></a> unless the feature is disabled via <code>features: [-sidenotes]</code>.</p> </div> <div id="sidenotes" class="section level3"> <h3>Sidenotes</h3> <p>Sidenotes can be generated via a div with classes <code>side</code> and <code>side-left</code> or <code>side-right</code>. You can use either the HTML syntax <code>&lt;div class="side side-left"&gt;</code> or Pandoc’s fenced <code>Div</code>, e.g.,</p> <div class="side side-right"> <p>This is a <strong>sidenote</strong> on the right side when the window is wider than 1264px.</p> </div> <pre class="md"><code>::: {.side .side-right} This is a **sidenote** on the right. :::</code></pre> </div> <div id="citations" class="section level3"> <h3>Citations</h3> <p>Use <code>bibliography</code> or <code>references</code> in YAML to include the bibliography database, and use <code>@</code> to cite items, e.g., <code>@R-base</code> generates <span class="citation">R Core Team (<a href="#ref-R-base">2023</a>)</span>.</p> <pre class="r"><code>knitr::write_bib(&#39;base&#39;, &#39;packages.bib&#39;)</code></pre> <p>As you can see above, we generated a <code>.bib</code> database with <code>knitr::write_bib()</code>.</p> <p>Citation entries are displayed in the right margin by default like footnotes. To disable this behavior, set <code>features: [-sidenotes]</code> in YAML.</p> <div id="refs" class="references csl-bib-body hanging-indent"> <div id="ref-R-base" class="csl-entry"> R Core Team. 2023. <em>R: A Language and Environment for Statistical Computing</em>. Vienna, Austria: R Foundation for Statistical Computing. <a href="https://www.R-project.org/">https://www.R-project.org/</a>. </div> </div> </div> </div> <div class="footnotes footnotes-end-of-document"> <hr /> <ol> <li id="fn1"><p>Apply the option <code>number_sections: true</code> to the output format <code>blogdown::html_page</code> in YAML.<a href="#fnref1" class="footnote-back">↩︎</a></p></li> <li id="fn2"><p>For example, this is a footnote.<a href="#fnref2" class="footnote-back">↩︎</a></p></li> </ol> </div>
yihui/hugo-prose
112
A Hugo theme derived from the XMin theme, and inspired by Wowchemy, Distill, and tufte.css
HTML
yihui
Yihui Xie
rstudio swissre merck
exampleSite/content/post/2020-11-10-r-markdown-demo/index_files/header-attrs/header-attrs.js
JavaScript
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to // be compatible with the behavior of Pandoc < 2.8). document.addEventListener('DOMContentLoaded', function(e) { var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); var i, h, a; for (i = 0; i < hs.length; i++) { h = hs[i]; if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 a = h.attributes; while (a.length > 0) h.removeAttribute(a[0].name); } });
yihui/hugo-prose
112
A Hugo theme derived from the XMin theme, and inspired by Wowchemy, Distill, and tufte.css
HTML
yihui
Yihui Xie
rstudio swissre merck
exampleSite/layouts/shortcodes/blogdown/postref.html
HTML
{{ if eq (getenv "HUGO_BLOGDOWN_POST_RELREF") "true" }}{{ .Page.RelPermalink }}{{ else }}{{ .Page.Permalink }}{{ end }}
yihui/hugo-prose
112
A Hugo theme derived from the XMin theme, and inspired by Wowchemy, Distill, and tufte.css
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/404.html
HTML
{{ partial "header.html" . }} <div class="container"> <main> <h1>404 NOT FOUND</h1> </main> </div> {{ partial "footer.html" . }}
yihui/hugo-prose
112
A Hugo theme derived from the XMin theme, and inspired by Wowchemy, Distill, and tufte.css
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/_default/list.html
HTML
{{ partial "header.html" . }} <div class="container list"> <main> {{ if not .IsHome }} <h1>{{ .Title }}</h1> {{ end }} {{ with .Content }} <section class="article-list"> <div>{{ . }}</div> </section> {{ end }} {{ if .IsHome }} {{ range $i, $p := (where .Site.RegularPages "Section" "card") }} <section class="article-list"{{ with .Params.style }}{{ printf " style=%q" . | safeHTMLAttr }}{{ end }}> <table> <tbody> <tr> {{if (eq (mod $i 2) 0) }} <td class="side-title"><h1>{{ $p.Title }}</h1></td> <td class="spacer spacer-left"></td> <td>{{ $p.Content }}</td> {{ else }} <td>{{ $p.Content }}</td> <td class="spacer spacer-right"></td> <td class="side-title"><h1>{{ $p.Title }}</h1></td> {{ end }} </tr> </tbody> </table> </section> {{ end }} {{ end }} {{ $pages := .Pages }} {{ if .IsHome }} {{ $pages = first (default 6 .Site.Params.homePosts) (sort (where .Site.RegularPages "Type" "in" .Site.Params.mainSections) "Date" "desc") }} {{ else }} {{ $pages = (.Paginate $pages).Pages }} {{ end }} {{ range $pages }} <section class="article-list post-card{{ if .Draft }} draft{{ end }}"> <table> <tbody> <tr> <td> {{ with .Params.categories }} {{ range first 1 . }} <div class="categories"> <a href="{{ relURL (print "/categories/" . "/" | urlize) }}">{{ . }}</a> </div> {{ end }} {{ end }} <h1><a href="{{ .RelPermalink }}">{{ .Title }}</a></h1> <div> {{ if .Date }}<span>{{ .Date.Format "2006-01-02" }}</span>{{ end }} {{ with .Params.author }}<span>{{ . }}</span>{{ end }} </div> <div class="summary"> {{ $summary := .Description }} {{ if $summary }} {{ $summary = (markdownify $summary) }} {{ else }} {{ $summary = ((delimit (findRE "(<p.*?>(.|\n)*?</p>\\s*)+" .Content) "[&hellip;] ") | plainify | truncate (default 200 .Site.Params.summaryLength) (default " &hellip;" .Site.Params.textTruncated ) | replaceRE "&amp;" "&") }} {{ end }} {{ $summary | replaceRE "^([A-Za-z])" "&$1 opf;" | replaceRE "^(&[A-Za-z]) (opf;)" "$1$2" | safeHTML }} <a href="{{ .RelPermalink }}" class="more" title={{ i18n "readMore" }}>{{ i18n "readMore" }} &rarr;</a> </div> </td> {{ if $.IsHome }} <td class="spacer spacer-right"></td> <td class="side-title">{{ with .Section }}<h1><a href="{{ print "/" . "/" | relURL }}">{{ . }}</a></h1>{{ end }}</td> {{ end }} </tr> </tbody> </table> </section> {{ end }} {{ if not .IsHome }} {{ template "_internal/pagination.html" . }} {{ end }} {{ partial "disqus.html" . }} </main> </div> {{ partial "footer.html" . }}
yihui/hugo-prose
112
A Hugo theme derived from the XMin theme, and inspired by Wowchemy, Distill, and tufte.css
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/_default/single.html
HTML
{{ partial "header.html" . }} <div class="container single"> <main> {{ if .Draft }} <div class="watermark">Draft</div> {{ end }} <div class="article-meta"> <h1><span class="title">{{ .Title }}</span></h1> {{ with .Params.author }} <h3 class="author"> {{ if reflect.IsSlice . }}{{ delimit . (default " / " $.Site.Params.authorDelimiter) }}{{ else }}{{ . }}{{ end }} </h3> {{ end }} {{ if .Params.date }}<h3 class="date">{{ .Date.Format "2006-01-02" }}</h3>{{ end }} <p class="terms"> {{ range $i := (slice "categories" "tags") }} {{ with ($.Param $i) }} {{ $i | title }}: {{ range $k := . }}<a href="{{ relURL (print "/" $i "/" $k | urlize) }}">{{$k}}</a> {{ end }} {{ end }} {{ end }} </p> </div> <div class="article"> {{ .Content }} </div> </main> {{ partial "appendix.html" . }} {{ if .Section }} <nav class="post-nav"> <span class="nav-next">{{ with .PrevInSection }}&larr; <a href="{{ .RelPermalink }}" title={{ i18n "nextPost" }}>{{ .Title }}</a>{{ end }}</span> &hercon; <span class="nav-prev">{{ with .NextInSection }}<a href="{{ .RelPermalink }}" title={{ i18n "previousPost" }}>{{ .Title }}</a> &rarr;{{ end }}</span> </nav> {{ end }} {{ partial "disqus.html" . }} </div> {{ $.Scratch.Set "has_appendix" true }} {{ partial "footer.html" . }}
yihui/hugo-prose
112
A Hugo theme derived from the XMin theme, and inspired by Wowchemy, Distill, and tufte.css
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/_default/sitemap.html
HTML
{{ partial "header.html" . }} <div class="container"> <main> <h1>{{ .Title }}</h1> {{ .Content }} {{ range .Site.RegularPages.GroupBy "Section" }} <section class="article-list normal-card"> <h2 class="archive-title"><a href="{{ print "/" .Key "/" | relURL }}">{{ .Key | pluralize | title }}</a></h2> <ul> {{ range sort .Pages "Date" "desc" }} <li> {{ if .Date }}<span class="date">{{ .Date.Format "2006/01/02" }}</span>{{ end }} <a href="{{ .RelPermalink }}">{{ .Title }}</a> </li> {{ end }} </ul> </section> {{ end }} </main> </div> {{ partial "footer.html" . }}
yihui/hugo-prose
112
A Hugo theme derived from the XMin theme, and inspired by Wowchemy, Distill, and tufte.css
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/_default/terms.html
HTML
{{ partial "header.html" . }} <main class="container"> <h1>{{ .Title }}</h1> <ul class="terms"> {{ range (index .Site.Taxonomies (.Title | lower)) }} <li><a href="{{ .Page.RelPermalink }}">{{ .Page.Title }} <span class="bg-number">{{ .Count }}</span></a></li> {{ end }} </ul> </main> {{ partial "footer.html" . }}
yihui/hugo-prose
112
A Hugo theme derived from the XMin theme, and inspired by Wowchemy, Distill, and tufte.css
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/partials/appendix.html
HTML
<section class="appendix"> {{ if $.Site.Data.authors }} {{ if .Params.author }} <div> <div class="side side-left"><h3>{{ i18n "authorsBio" }}</h3></div> <div>{{ partial "bio.html" . }}</div> </div> {{ end }} {{ end }} {{ range $key, $value := .Params.appendix }} <div> <div class="side side-left"><h3>{{ $key | title }}</h3></div> <div>{{ $value | markdownify }} </div> </div> {{ end }} {{ with (default .Params.license .Site.Params.license ) }} <div> <div class="side side-left"><h3>{{ i18n "reUse" }}</h3></div> {{ . | markdownify }} </div> {{ end }} {{ partial "correction.html" . }} {{ if .Params.author }} <div> <div class="side side-left"><h3>{{ i18n "citation" }}</h3></div> <p>{{ i18n "citationText" }}</p> <pre><code>{{ with .Params.author }}{{ if (reflect.IsSlice .) }}{{ delimit . ", " }}{{ else }}{{ . }}{{ end }}{{ end }} ({{ (or .Date now).Format "2006" }}). {{ .Title }}. {{ .Site.Title }}. {{ .Permalink}}</code></pre> <p>BibTeX citation</p> <pre><code>@misc{ title = "{{ .Title }}", author = "{{ with .Params.author }}{{ if (reflect.IsSlice .) }}{{ delimit . " and " }}{{ else }}{{ . }}{{ end }}{{ end }}", year = "{{ (or .Date now).Format "2006" }}", journal = "{{ .Site.Title }}", note = "{{ .Permalink }}" }</code></pre> </div> {{ end }} </section>
yihui/hugo-prose
112
A Hugo theme derived from the XMin theme, and inspired by Wowchemy, Distill, and tufte.css
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/partials/bio.html
HTML
{{ with .Params.author }} {{ $author := . }} {{ if not (reflect.IsSlice $author) }} {{ $author = (slice $author) }} {{ end }} {{ range (where $.Site.Data.authors "name" "in" $author) }} <div>{{ .bio | markdownify }}</div> {{ end }} {{ end }}
yihui/hugo-prose
112
A Hugo theme derived from the XMin theme, and inspired by Wowchemy, Distill, and tufte.css
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/partials/correction.html
HTML
{{ if (and .File .Site.Params.editLink) }} <div> <div class="side side-left"><h3>{{ i18n "suggestChanges" }}</h3></div> {{ $filePath := path.Clean .File.Path }} {{ $RmdFile := (print .File.Dir .File.BaseFileName ".Rmd") }} {{ if (fileExists (print "content/" $RmdFile)) }} {{ $filePath = $RmdFile }} {{ else }} {{ $RmdFile = (print .File.Dir .File.BaseFileName ".Rmarkdown") }} {{ if (fileExists (print "content/" $RmdFile)) }} {{ $filePath = $RmdFile }} {{ end }} {{ end }} {{ i18n "suggestChangesText1" }}<a href="{{ .Site.Params.editLink }}{{ $filePath }}" id="edit-link">{{ i18n "suggestChangesText2" }}</a> </div> {{ end }}
yihui/hugo-prose
112
A Hugo theme derived from the XMin theme, and inspired by Wowchemy, Distill, and tufte.css
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/partials/disqus.html
HTML
<!-- copied from https://github.com/rbind/yihui/blob/master/layouts/partials/disqus.html --> {{ if and (not (eq .Site.Config.Services.Disqus.Shortname "")) (and (not .Params.disable_comments) (or (eq .Kind "404") (and (not .IsHome) .Content))) }} <section class="comments"> <div id="disqus_thread"></div> <script> var disqus_config = function () { {{ with .Site.Params.disqusURL }} this.page.url = "{{ . }}" +{{ if eq $.Kind "404" }} "/404.html" {{ else }} location.pathname{{ end }}; {{ end }} }; (function() { var inIFrame = function() { var iframe = true; try { iframe = window.self !== window.top; } catch (e) {} return iframe; }; if (inIFrame()) return; var disqus_js = '//{{ .Site.Config.Services.Disqus.Shortname }}.disqus.com/embed.js'; var d = document, s = d.createElement('script'); s.src = disqus_js; s.async = true; s.setAttribute('data-timestamp', +new Date()); var t = d.getElementById('disqus_thread'); var b = false, l = function(scroll) { if (b) return; (d.head || d.body).appendChild(s); b = true; if (scroll) t.scrollIntoView(); } s.onerror = function(e) { if (sessionStorage.getItem('failure-note')) return; t.innerText = 'Sorry, but you cannot make comments because Disqus failed to load for some reason. It is known to be blocked in China. If you are sure it is not blocked in your region, please refresh the page. 中国大陆地区读者需要翻墙才能发表评论。'; t.style.border = '1px dashed'; t.style.padding = '.5em'; t.style.background = 'lightyellow'; sessionStorage.setItem('failure-note', true); }; // show comments when the hash means to jump to a comment if (location.hash.match(/^#comment-[0-9]+$/)) return l(true); var c = function() { if (b) return; var rect = t.getBoundingClientRect(); if (rect.top < window.innerHeight && rect.bottom >= 0) l(); }; window.addEventListener('load', c); d.addEventListener('scroll', c); })(); </script> <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> </section> {{ end }}
yihui/hugo-prose
112
A Hugo theme derived from the XMin theme, and inspired by Wowchemy, Distill, and tufte.css
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/partials/foot_custom.html
HTML
{{ with .Site.Params.fuseVersion }} <script src="https://cdn.jsdelivr.net/npm/fuse.js@{{ . }}"></script> {{ end }} {{ if and (not .Params.disable_mathjax) (or (in (string .Content) "\\") (in (string .Content) "$")) }} <script src="//yihui.org/js/math-code.js"></script> <script async src="//mathjax.rstudio.com/latest/MathJax.js?config=TeX-MML-AM_CHTML"></script> {{ end }} {{ template "_internal/google_analytics.html" . }} {{ if .IsPage }} <script src="https://cdn.jsdelivr.net/combine/npm/@xiee/utils/js/number-sections.min.js,npm/@xiee/utils/js/toc.min.js,npm/@xiee/utils/js/toc-highlight.min.js,npm/@xiee/utils/js/sidenotes.min.js,npm/@xiee/utils/js/right-quote.min.js,npm/@xiee/utils/js/center-img.min.js,npm/@xiee/utils/js/fix-pandoc.min.js,npm/@xiee/utils/js/heading-anchor.min.js" defer></script> {{ end }} {{ if and (not .Params.disable_highlight) (in (string .Content) "</pre>") }} <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@xiee/utils/css/prism-xcode.min.css"> <script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-core.min.js" defer></script> <script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/plugins/autoloader/prism-autoloader.min.js" defer></script> {{ end }}
yihui/hugo-prose
112
A Hugo theme derived from the XMin theme, and inspired by Wowchemy, Distill, and tufte.css
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/partials/footer.html
HTML
<footer> {{ partial "foot_custom.html" . }} <div class="footer"> {{ with .Site.Params.footer }} <ul class="copyright"> <li>{{ . | markdownify }}</li> </ul> {{ end }} <ul> {{ range .Site.Menus.footer }} <li{{ with .Pre }} class="{{ . }}"{{ end }}{{ with .Identifier }} id="{{ . }}"{{ end }}> <a href="{{ if (findRE "^#" .URL ) }}{{ .URL }}{{ else }}{{ .URL | relURL }}{{ end }}">{{ .Name }}</a> </li> {{ end }} </ul> </div> {{ if not ($.Scratch.Get "has_appendix") }} <div class="footer hidden"> {{ partial "correction.html" . }} </div> {{ end }} </footer> <script src="{{ relURL "/js/features.js" }}" defer></script> </body> </html>
yihui/hugo-prose
112
A Hugo theme derived from the XMin theme, and inspired by Wowchemy, Distill, and tufte.css
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/partials/head_custom.html
HTML
{{ template "_internal/twitter_cards.html" . }}
yihui/hugo-prose
112
A Hugo theme derived from the XMin theme, and inspired by Wowchemy, Distill, and tufte.css
HTML
yihui
Yihui Xie
rstudio swissre merck
layouts/partials/header.html
HTML
<!DOCTYPE html> <html lang="{{ .Site.LanguageCode }}"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>{{ with .Title }} {{ . }} | {{ end }}{{ .Site.Title }}</title> <!-- uncomment this to add favicon --> <!-- <link rel="icon" type="image/png" href="{{ "/icons/favicon.png" | relURL }}" /> --> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@xiee/utils@v1.13.54/css/article.min.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@xiee/utils/css/heading-anchor.min.css"> <link rel="stylesheet" href="{{ "/css/style.css" | relURL }}" /> <link rel="stylesheet" href="{{ "/css/fonts.css" | relURL }}" /> <link rel="stylesheet" href="{{ "/css/custom.css" | relURL }}" /> {{ partial "head_custom.html" . }} </head> <body{{ if .Draft }} class="draft"{{ end }}> <nav class="menu{{ if .Site.Params.stickyMenu }} sticky-top{{ end }}"> <ul> <li class="left"> <a href="{{ relURL "/" }}"><span>{{ .Site.Title }}</span></a> </li> {{ range .Site.Menus.header }} <li{{ with .Pre }} class="{{ . }}"{{ end }}{{ with .Identifier }} id="{{ . }}"{{ end }}> <a href="{{ .URL | relURL }}"{{ if eq .URL $.RelPermalink }} class="active"{{ end }}>{{ .Pre }}{{ .Name }}{{ .Post }}</a> </li> {{ end }} </ul> </nav>
yihui/hugo-prose
112
A Hugo theme derived from the XMin theme, and inspired by Wowchemy, Distill, and tufte.css
HTML
yihui
Yihui Xie
rstudio swissre merck
static/css/fonts.css
CSS
body { font-family: Optima, Candara, Calibri, "Droid Sans", Arial, sans-serif; } code { font-family: "Lucida Console", Monaco, monospace; font-size: 85%; } h1, h2, h3 { font-family: Palatino, Book Antiqua, serif; }
yihui/hugo-prose
112
A Hugo theme derived from the XMin theme, and inspired by Wowchemy, Distill, and tufte.css
HTML
yihui
Yihui Xie
rstudio swissre merck
static/css/style.css
CSS
/* overall layout */ * { box-sizing: border-box; } body { margin: 0 auto 0; line-height: 1.5; overflow-x: hidden; } main, .menu ul, .footer, .single section, .post-nav { max-width: 800px; margin: 0 auto 0; } main { display: block; hyphens: auto; } .list main { display: flex; flex-wrap: wrap; justify-content: space-between; & > * { flex: 1 0 100%; } & > .post-card { flex: 0 0 calc(50% - .5em); } } .menu, .container { padding: 0 1em 0; } .post-card { margin-top: 1em; } .article-list, .single main, .single .appendix { margin-top: 2em; padding: 1em; box-shadow: 0 0 8px #ccc; background: #fff; } .article-meta { background: #f8f8f8; } .article-meta .terms, main .side > *, figcaption { font-size: .9em; } .single .appendix { background: none; } /* header and footer areas */ .menu { background: #fafafa; box-shadow: 0px 10px 10px -5px rgba(0,0,0,0.1); } .sticky-top { position: sticky; top: 0; z-index: 2; } .menu li, .terms li, .footer li { display: inline-block; } footer { background: darkslategray; } .menu ul { padding: 1em 0 1em; display: flex; } .article-meta, .menu a, .footer a, .terms a, .bg-number { text-decoration: none; padding: 5px; border-radius: 5px; } .menu a, .footer a { margin: 1px; } .menu a, .pagination a, .article-meta a { color: darkslategray; } .menu a:hover, .menu .active, .summary::first-letter, .footer a:hover, .terms a:hover, .bg-number { background: lightslategray; color: #fff; } .menu, .article-meta, .post-nav { text-align: center; } .menu ul, .terms, .footer ul { padding-left: 0; } .menu .left { flex-grow: 1; font-weight: 600; text-align: left; } .title { font-size: 1.1em; line-height: 1em; } .terms a { border: 1px solid lightslategray; line-height: 2em; } .terms a, .bg-number { padding: 1px 5px; } .footer { display: flex; justify-content: space-between; a { text-decoration: none; } } footer { margin-top: 2em; } hr { border-style: dashed; color: #ddd; width: 50%; } .footnotes hr { margin-left: 0; } .appendix div:not(:last-child):not(.side) { border-bottom: 1px dashed lightslategray; padding-bottom: 1em; margin-bottom: 1em; } /* code */ pre code { display: block; padding: 1em; border: 1px solid #ddd; overflow-x: auto; } .appendix pre code { white-space: pre-wrap; } h3.side-left { text-align: right; } .spacer { width: 1em; } .spacer-left { border-left: 1px dashed; } .spacer-right { border-right: 1px dashed; } /* search */ .search .menu li, .search .container, .search footer, .search-results { display: none; } .search #menu-search, .search .search-results { display: flex; width: 100%; } .search #menu-search div:first-child { flex-grow: 1; } .search input, .search #menu-search a { padding: .5em; font-size: 1.5em; } .search input { width: 100%; background: transparent; border: none; border-bottom: 2px solid lightslategray; } .search-results b { font-weight: normal; background: orange; } /* misc elements */ img, iframe, video { max-width: 100%; } iframe, video { display: block; margin: auto; } .title, code, .article-list .side-title { hyphens: none; } blockquote, code, .article tbody tr:nth-child(odd) { background: #f9f9f9; } blockquote { border-left: 5px solid #ccc; padding: 1px 0 1px 1em; margin: auto; } .categories { text-transform: uppercase; font-size: .8em; } .article-list a, .footer a { text-decoration: none; color: #000; } .article-list h1 { a { width: 100%; display: inline-block; } a:hover { color: #71a5d4; } border-bottom: 1px solid #ddd; margin: 5px 0px 10px; } .article-list { .side-title { transform: rotate(90deg); } &:nth-child(even):not(.post-card) .side-title { transform: rotate(-90deg); } table { margin: 0; border: none; border-collapse: collapse; width: 100%; table-layout: fixed; } td { padding: 0; } } #TOC { .numbered { padding-left: 0; li { list-style: none; } ul { padding-left: 1em; } } .active { font-weight: bold; } } .side-title { width: 3em; } .side-title h1 { border: none; } .post-card .side-title h1 a, .post-card .spacer-right, .appendix h3 { color: lightslategray; } .appendix h3 { text-align: right; } .summary { margin-top: .5em; } .summary::first-letter { font-size: 3.5em; padding: .1em .2em .1em .1em; margin: 0 .1em 0 0; display: inline-block; float: left; line-height: 1em; } .pagination { text-align: center; } .pagination li { display: inline; } .pagination a { padding: 0 .2em; } .active a, #TOC a { text-decoration: none; } .post-nav { margin: 1em auto; } .post-nav span { display: inline-block; width: 45%; } .nav-prev { text-align: right; } .nav-next { text-align: left; } .footer, .footer a { color: #fff; } .more { font-style: italic; } .hidden { display: none; } .draft { background: repeating-linear-gradient( 135deg, white, white 10px, #ffd4a3 12px, #ffd4a3 12px ); } .watermark { position: fixed; transform: rotate(-45deg); font-size: 12em; width: 100%; color: lightgray; opacity: 0.3; left: 0; text-align: center; top: 50%; } table { margin: 1em auto auto; border-top: 1px solid #666; border-bottom: 1px solid #666; } table thead th { border-bottom: 1px solid #ddd; } th, td { padding: 5px; } /* responsive */ @media (max-width: 1264px) { .appendix h3 { text-align: initial; } } @media (max-width: 800px) { li.optional { display: none; } .article-list { margin-top: 1.5em; } .list main .post-card { flex: inherit; } .menu ul, .footer { flex-wrap: wrap; } .search input, .search #menu-search a { font-size: 1em; } } /* dark theme */ @media (prefers-color-scheme: dark) { body { background-color: darkslategray; filter: invert(1); } img { filter: invert(1); } .article-list { box-shadow: 0 0 8px #333; } }
yihui/hugo-prose
112
A Hugo theme derived from the XMin theme, and inspired by Wowchemy, Distill, and tufte.css
HTML
yihui
Yihui Xie
rstudio swissre merck
static/js/features.js
JavaScript
(function(d) { // move <figcaption> out of <figure> (and p.caption out of div.figure) so that <figure> can scroll d.querySelectorAll('.fullscroll figure > figcaption, .fullscroll .figure > .caption').forEach(el => { el.parentNode.after(el); }); // make TOC stiky beneath the top menu const menu = d.querySelector('.menu'), toc = d.querySelector('#TOC'); if (menu?.classList.contains('sticky-top')) { if (toc) toc.style.top = menu.offsetHeight + 'px'; } toc?.classList.add('side', 'side-left'); // add the edit link to the menu "Suggest an edit" let s = d.querySelector('li#menu-edit'); if (s) { const a = d.querySelector('a#edit-link'); if (a) { s = s.querySelector('a[href="#"]'); if (s) s.href = a.href; } else { s.remove(); // no edit link available; delete the menu item } } // search const a = d.querySelector('li#menu-search > a'); if (a) { let t = a.innerText, fuse; a.addEventListener('click', function(e) { e.preventDefault(); s = a.previousElementSibling; // the search input if (a.innerText === '×') { if (s) s.style.display = 'none'; d.body.classList.remove('search'); a.innerText = t; // restore menu text return; } if (!s) { s = document.createElement('div'); s.innerHTML = '<input type="search" class="search-input" disabled placeholder="Loading search index...">'; const input = s.firstElementChild; a.before(s); const c = d.createElement('div'); // container for search results c.className = 'container list search-results'; const m = d.createElement('main'); c.appendChild(m); d.querySelector('.container').before(c); // Esc to close search box when it's empty input.addEventListener('keydown', function(e) { if (this.value === '' && e.key === 'Escape') a.click(); }); // may need to debounce the search for better performance and UX input.addEventListener('input', function(e) { if (!fuse) return; // highlight the keyword of the maximum length in content function highlight(text, matches, len) { let indices; for (let item of matches) { if (item.key === 'content') indices = item.indices; } if (!indices) return text.substr(0, len); let p, pair, k = 0, n = Math.ceil(len / 2); while (pair = indices.shift()) { if (pair[1] - pair[0] >= k) { p = pair; k = p[1] - p[0]; } } return (p[0] - n > 0 ? '[...] ' : '') + text.substring(p[0] - n, p[0]) + '<b>' + text.substring(p[0], p[1] + 1) + '</b>' + text.substring(p[1] + 1, p[1] + 1 + n) + (p[1] + 1 + n < text.length ? ' [...] ' : ''); }; let res, sec = d.createElement('section'), sec2, h, u, sum; sec.className = 'article-list'; m.innerHTML = ''; // display search results in <section class="article-list"> and highlight keywords for (res of fuse.search(this.value)) { sec2 = sec.cloneNode(); h = d.createElement('h1'); u = d.createElement('a'); u.href = res.item.uri; u.target = '_blank'; u.innerText = res.item.title; h.appendChild(u); sum = d.createElement('div'); sum.innerHTML = highlight(res.item.content, res.matches, 300); sec2.appendChild(h); sec2.appendChild(sum); m.appendChild(sec2); }; }); if (!fuse) { const request = new XMLHttpRequest(); request.responseType = 'json'; request.addEventListener('load', function(e) { const res = request.response; if (!res || res.length === 0) { input.placeholder = 'Failed to load search index'; return; } input.disabled = false; input.placeholder = 'Type to search'; input.focus(); fuse = new Fuse(request.response, { keys: ['title', 'content'], includeMatches: true, ignoreLocation: true, threshold: 0.1 }); }, false); request.open('GET', '/index.json'); // if Fuse has not been loaded, load the latest version from CDN if (!window.Fuse) { const script = d.createElement('script'); script.src = 'https://cdn.jsdelivr.net/npm/fuse.js/dist/fuse.js'; // fetch the search index after Fuse is ready script.onload = function(e) { request.send(null); }; d.head.appendChild(script); } else { request.send(null); } } } s.style.display = 'block'; s.firstElementChild.focus(); a.innerText = '×'; d.body.classList.add('search'); }); } })(document);
yihui/hugo-prose
112
A Hugo theme derived from the XMin theme, and inspired by Wowchemy, Distill, and tufte.css
HTML
yihui
Yihui Xie
rstudio swissre merck
compile.R
R
options(repos = "https://cran.rstudio.com") dir.create('~/R', showWarnings = FALSE) .libPaths('~/R') # install xfun and tinytex pkg_install = function(...) install.packages(..., quiet = TRUE) pkg_install('xfun') options(xfun.install.package = pkg_install) xfun::pkg_load2(c('tinytex', 'rmarkdown')) # install TinyTeX suppressMessages(suppressWarnings(if (!tinytex:::is_tinytex()) tinytex::install_tinytex())) p0 = tinytex::tl_pkgs() # the initial set of LaTeX packages installed p1 = NULL # missing packages identified from the LaTeX log # parse LaTeX errors from .log files, or compile .Rmd/.tex files to figure out # missing LaTeX packages for (f in list.files('.', '[.](Rmd|tex|log)$')) { if (!file.exists(f)) next # the file might have been deleted # different actions according to filenames extensions switch( xfun::file_ext(f), Rmd = if (length(grep('^---\\s*$', readLines(f, n = 1)))) { # the first line needs to be ---, in case it's a child Rmd file xfun::pkg_load2('rmarkdown') # make sure pandoc and pandoc-citeproc are installed for (i in c('pandoc', 'pandoc-citeproc')) { if (Sys.which(i) == '') system(paste('brew install', i)) } rmarkdown::render(f) }, tex = { x = xfun::read_utf8(f) # need to find \documentclass or \begin{document} in the .tex file if (length(grep('\\\\documentclass', x)) == 0) next n1 = length(i1 <- grep('\\\\begin\\{document\\}', x)) n2 = length(i2 <- grep('\\\\end\\{document\\}', x)) if (n1 * n2 == 0) next if (n1 > 1 || n2 > 1) { warning('More than one line of code contains \\begin{document} or \\end{document}') next } # clear the document body, because it may have references to files that # users forgot or didn't want to upload to this repo; this approach won't # work for bibliography, but users can upload their LaTeX log in this case xfun::write_utf8(c(x[1:i1], 'Hello world!', x[i2]), f) r = '.*?((?:pdf|xe|lua)latex).*' engine = if (length(grep(r, f))) gsub(r, '\\1', f) # also try to infer engine from the comment like "% !TeX program = xelatex" r = '^(?:% !TeX program\\s*=\\s*)([[:alnum:]-]+).*' if (length(i <- grep(r, x))) engine = gsub(r, '\\1', x[i][1]) # if I can't infer the engine, use pdflatex by default if (is.null(engine)) engine = 'pdflatex' r = '.*?(bibtex|biber).*' bib_engine = if (length(grep(r, f))) gsub(r, '\\1', f) if (is.null(bib_engine)) bib_engine = 'bibtex' tinytex::latexmk(f, engine = engine, bib_engine = bib_engine) }, log = { if (file.size(f) == 0) next p1 = c(p1, tinytex::parse_packages(f)) } ) } p2 = setdiff(tinytex::tl_pkgs(), p0) # newly installed packages after compiling Rmd/tex files saveRDS(list(p1, p2), file = 'packages.rds')
yihui/latex-pass
52
Help you pass the LaTeX compilation by telling you which LaTeX packages are missing to compile your documents
R
yihui
Yihui Xie
rstudio swissre merck
latex-pass.R
R
.libPaths('~/R') pp = readRDS('packages.rds') p1 = pp[[1]]; p2 = pp[[2]] one_string = function(..., s = ' ') paste(..., collapse = s) msg = c( if (length(p1)) c('The missing packages identified from the LaTeX log are:\n\n ', one_string(p1)), if (length(p2)) c('\n\nAdditional packages required to compile your documents are:\n\n ', one_string(p2)) ) msg2 = if (length(msg)) { p = sort(unique(c(p1, p2))) c( sprintf( '\n\nIf you are an R user using TinyTeX, you may install these packages via:\n\n tinytex::tlmgr_install(c(%s))', one_string(sprintf("'%s'", p), s = ', ') ), '\n\nIf you use TinyTeX, including LaTeX for Manim (https://chocolatey.org/packages/manim-latex), you may install these packages via command line:\n\n tlmgr install ', one_string(p), '\n\nIf you do not use TinyTeX (https://yihui.org/tinytex/), you need to figure out how to install them by yourself.' ) } else { msg = 'I did not figure out which LaTeX packages you need to install. Sorry.' "" } message(msg, msg2) writeLines(one_string(msg, s = ''), 'message.txt') writeLines(one_string(msg2, s = ''), 'details.txt')
yihui/latex-pass
52
Help you pass the LaTeX compilation by telling you which LaTeX packages are missing to compile your documents
R
yihui
Yihui Xie
rstudio swissre merck
build.sh
Shell
#!/bin/sh set -e npm install lightningcss-cli terser -g cd js for i in *.js; do terser $i --compress --mangle --source-map "url='${i%.*}.min.js.map'" --output ${i%.*}.min.js done cd ../css for i in *.css; do lightningcss --minify --sourcemap -o ${i%.*}.min.css $i done cd ..
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
css/article.css
CSS
:root { --side-width: 200px; --side-gap: 2em; --side-margin: calc(0px - var(--side-width) - var(--side-gap)); } body, blockquote, .side { background: #fafafa; } .body, .body ~ .appendix, .frontmatter, .fullwidth, .embed-left, .embed-right { margin-top: 2em; padding: 1em; box-shadow: 0 0 8px #ccc; background: #fff; } .appendix, .footnotes, .body .side { font-size: .9em; } .body ~ .appendix, .frontmatter { background: none; } .appendix h2 { border-bottom: 1px dashed #666; } #TOC { top: 0; } .bg-number { padding: 1px 5px; border-radius: 5px; background: lightslategray; color: #fff; } div:not(.body):has(> table) { overflow-x: auto; } /* left/right elements*/ .side { width: var(--side-width); margin: 0 auto; max-height: 100vh; overflow: auto; } .side-left { float: left; clear: left; margin-left: var(--side-margin); &:not(.body > *) { margin-left: calc(var(--side-margin) + 1em); } position: sticky; } .side-right { float: right; clear: right; margin-right: var(--side-margin); } .quote-left, .quote-right { width: 45%; } .embed-left, .embed-right { margin-top: auto; padding: 0; } .quote-left, .embed-left { float: left; margin-right: 1em; } .quote-right, .embed-right { float: right; margin-left: 1em; } .embed-left { margin-left: var(--side-margin); } .embed-right { margin-right: var(--side-margin); } :is(.side, .embed-left, .embed-right) > :first-child { margin-top: 0; } :is(.embed-left, .embed-right) > :last-child { margin-bottom: 0; } :is(.quote-left, .quote-right) { & > :first-child { padding-top: .1px; } & > :last-child { padding-bottom: .1px; } } /* wide elements */ .fullwidth { max-width: calc(100vw - 2em); margin: 1em 0 1em 50%; transform: translateX(-50%); float: left; min-width: 100%; background: #fff; & * { max-width: calc(100vw - 4em); margin: auto 0; } & :is(figcaption, .caption) { margin-left: calc(50% - 400px); width: 800px; padding: 1em 1em 0; } } .fullscroll { & * { max-width: initial; } &, & figure, & .figure { overflow-x: auto; } } @media (min-width: 1264.02px) { #TOC.side { .active { color: limegreen; } li li .active { border-left: 3px solid; margin-left: calc(-1em - 3px); padding-left: 1em; } &:has(.active) li:not(:has(.active)) ul { display: none; } } .note-ref { cursor: pointer; } .note-ref:hover + .side { display: inline-block; background: #f8f8f8; position: absolute; z-index: 1; margin-left: 1em; padding: .5em; box-sizing: content-box; } } @media (max-width: 1264px) { body:not(.pagesjs) { #TOC { border: 1px solid #eee; border-radius: 5px; padding: 1em; position: initial; float: none; columns: 2; } .side { width: 100%; } :is(main, .body) .side { padding: 0 2em; color: darkslategray; } .side-left, .side-right { clear: both; margin: 1em auto; background: none; } :not(.note-ref) + .side { float: none; } .footnote-ref + .footnotes { float: left; } .side > :last-child { margin-bottom: 0; } .embed-left, .embed-right { float: inherit; margin: auto; padding: 1em; } } } @media (max-width: 800px) { body:not(.pagesjs) { padding: initial; main, .body { padding: 0 .5em 0; } #TOC { columns: 1; } :not(pre) > code { word-break: break-word; } .quote-left, .quote-right { width: inherit; float: inherit; margin: auto; } .fullwidth { margin: initial; transform: initial; float: none; min-width: initial; background: none; border: none; & :is(figcaption, .caption) { margin: initial; padding: initial; } &:not(.fullscroll) * { max-width: 100%; } } } } @media print { body { background: none; } }
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
css/book-litedown.css
CSS
/* CSS for https://yihui.org/litedown/ */ /* hide 4th-level TOC items when printing to PDF and 3rd-level in chapter TOC */ .pagesjs #TOC > ul > li > ul > li > ul > li > ul, .chapter-toc > ul > li > ul > li > ul { display: none; } .pagesjs { #tab\:assets tr > :nth-child(2) { display: none; } } .epigraph { position: relative; padding: 5px; margin-bottom: 4em; &, blockquote { border: 1px solid; } &::before, &::after, blockquote::before, blockquote::after { content: "•"; position: absolute; border: 1px solid; display: inline-block; width: 1em; height: 1em; text-align: center; line-height: 1; } &::before { left: 5px; } &::after { content: "❀"; color: rebeccapurple; font-size: 3em; text-align: right; border: none; opacity: .2; inset: 5px 5px auto auto; } blockquote { padding: 1em; &::before { inset: auto auto 5px 5px; } &::after { inset: auto 5px 5px auto; } } &.pagesjs-fragmented { &:not(.fragment-first), &:not(.fragment-last) blockquote { &::before, &::after { display: none; } } &:not(.fragment-first) { &, blockquote { padding-top: 1px; } } &:not(.fragment-last) { &, blockquote { padding-bottom: 1px; } } } } /* a tale of two buttons */ .new-road { p { display: flex; justify-content: center; gap: .5em; } button::before { font-size: 200%; } .old-knit, .new-fuse { &:hover::before { content: "❓ "; } } .old-knit { &::before { content: "🧶 "; } &:focus::before { content: "😡 "; } } .new-fuse::before { content: "↯ "; } .new-preview::before { content: "⏵ "; } .new-fuse:focus::before { content: "😇 "; } } /* arrange elements in columns */ .flex-col { gap: .5em; * { flex: 1 0 min-content; } pre:has(code[data-file]) { &, &::before { border: groove mintcream; } code { border: none; border-top: 1px dashed lightgray; } & { border-top: none; } &::before { border-left: none; border-bottom: none; } } } code[data-file]::before { content: attr(data-file); font-size: .9em; float: right; background: lightyellow; display: inline-block; padding: .5em; margin: -1em -1em 1em 1em; } pre:has(code[data-file]) { &::before { content: "Output"; text-transform: uppercase; font-weight: bold; display: inline-block; padding: .5em 1em; border-bottom: none; } &:has(code[data-file$=".Rmd"])::before { content: "♧ Example"; } &:has(code[data-source])::before { content: "♧ Source"; } &.pagesjs-fragmented:first-child { &::before, code::before { content: unset; } } code, &::before { border: groove mintcream; } &::before { border-bottom: none; } } pre .ex-out::after { content: "⏵"; position: absolute; inset: auto 5px 0 auto; text-decoration: none; font-size: 1.5em; } .no-ref-label { .cross-ref-sec:before { content: ""; } } .larger { font-size: 1.5em; }
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
css/book.css
CSS
body { font-size: 1em; font-family: Palatino, Georgia, serif; } .footnotes, code, .side, .body .side, .chapter-toc { font-size: .85em; } .frontmatter, .chapter { min-height: calc(100vh - 1em); } .frontmatter { background-image: radial-gradient(#b6cee2 1px, #fff 1px); background-size: 2em 2em; background: #fff; padding-bottom: 0; & > div { margin: 0 -1em; background: #ebf6f9; padding: 1em; } & .title { padding: 20vh 1em 1em; margin-top: -1em; } } @media (min-width: 1264.02px) { body:not(.pagesjs) .chapter-toc { display: none; } } .chapter-toc { border: 1px solid #eee; border-radius: 5px; padding: 1em; margin-bottom: 2em; & > ul { columns: 18em; } } .chapter:not(.appendix) .main-number { &::before { content: "Chapter "; } &::after { content: none; } } .chapter h1 { margin: 1em auto 3em; border-bottom: 1px solid; &:has(+ .epigraph) { margin-bottom: 2em; } } h1 .section-number { display: inline-block; border-bottom: 4px solid; margin-bottom: -4px; } .body h2 { border-bottom-style: dashed; } /* TODO: style for h1.part and printing */ .pagesjs .pagesjs-page:first-child:has(.frontmatter) { padding: 0; .pagesjs-header, .pagesjs-footer { display: none; } .frontmatter { margin: 0; padding: var(--paper-margin-top) var(--paper-margin-right) var(--paper-margin-bottom) var(--paper-margin-left); height: 100%; .title { margin-top: calc(0px - var(--paper-margin-top)); } & > div { margin: 0 calc(0px - var(--paper-margin-right)) 0 calc(0px - var(--paper-margin-left)); } } }
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
css/callout.css
CSS
fieldset { font-size: .9em; margin: 1em auto; } legend { font-weight: bold; border-style: groove; padding: 2px .5em; background: white; } .callout { legend::before { content: var(--callout-icon); } legend::after { content: attr(data-legend); text-transform: uppercase; } background: var(--callout-background); &, legend { border-color: var(--callout-border); } } .callout-tip { --callout-border: honeydew; --callout-icon: "☆ "; } .callout-caution { --callout-border: aqua; --callout-background: azure; --callout-icon: "☂ "; } .callout-important { --callout-border: gold; --callout-background: lemonchiffon; --callout-icon: "☀ "; } .callout-note { --callout-border: lightskyblue; --callout-icon: "⚑ "; } .callout-warning { --callout-border: salmon; --callout-background: mistyrose; --callout-icon: "⚠ "; } .callout-example { --callout-border: mintcream; --callout-icon: "♧ "; }
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
css/circled-numbers.css
CSS
/* Add circled numbers to h2 and TOC items generated by Hugo */ #TableOfContents, #TableOfContents ~ p:first-of-type { counter-reset: circled-numbers; } h2:not([class])::before, #TableOfContents > ul > li > ul > li::before { counter-increment: circled-numbers; content: counter(circled-numbers); border-radius: 50%; border: 1px dashed #999; color: #333; background: white; display: inline-block; min-width: 1.75em; line-height: 1.75em; margin-right: .5em; text-align: center; font-size: .8em; } h2:not([class])::before { vertical-align: bottom; color: white; border: none; background: #999; } #TableOfContents > ul > li > ul > li { display: inline-block; }
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
css/code-line-numbers.css
CSS
span[data-line-number]::before { content: attr(data-line-number); padding-right: .5em; margin-right: 1em; display: inline-block; border-right: solid 1px; color: #ccc; }
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
css/copy-button.css
CSS
.copy-button { position: absolute; display: none; cursor: pointer; inset: 5px 5px auto auto; width: 1em; height: 1em; border: 1px solid; box-shadow: -3px 3px #999; } :is(:focus, :hover) > .copy-button { display: inline-block; } .copy-success { box-shadow: none; background: #999; transition: box-shadow 300ms ease-out, background 300ms ease-out; } .copy-fail { border-style: dotted; }
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
css/default.css
CSS
body { font-family: sans-serif; max-width: 800px; margin: auto; padding: 1em; line-height: 1.5; print-color-adjust: exact; -webkit-print-color-adjust: exact; } body, .abstract, code, .footnotes, footer, #refs, .caption { font-size: .9em; } li li { font-size: .95em; } ul:has(li > input[type="checkbox"]) { list-style: none; padding-left: 1em; } *, :before, :after { box-sizing: border-box; } a { color: steelblue; } pre, img { max-width: 100%; } pre { white-space: pre-wrap; word-break: break-word; } pre code { display: block; padding: 1em; overflow-x: auto; } code { font-family: 'DejaVu Sans Mono', 'Droid Sans Mono', 'Lucida Console', Consolas, Monaco, monospace; } :not(pre, th) > code, code[class], div > .caption { background: #f8f8f8; } pre > code:is(:not([class]), .language-plain, .language-none, .plain), .box, .figure, .table { background: inherit; border: 1px solid #eee; } pre > code { &.message { border-color: #9eeaf9; } &.warning { background: #fff3cd; border-color: #fff3cd; } &.error { background: #f8d7da; border-color: #f8d7da; } } .fenced-chunk { border-left: 1px solid #666; } .code-fence { opacity: .4; border: 1px dashed #666; border-left: 2px solid; &:hover { opacity: inherit; } } .box, .figure, .table, table { margin: 1em auto; } div > .caption { padding: 1px 1em; } .figure { p:has(img, svg), pre:has(svg) { text-align: center; } } .flex-col { display: flex; justify-content: space-between; } table { &:only-child:not(.table > *) { margin: auto; } th, td { padding: 5px; font-variant-numeric: tabular-nums; } thead, tfoot, tr:nth-child(even) { background: whitesmoke; } thead th { border-bottom: 1px solid #ddd; } &:not(.datatable-table) { border-top: 1px solid #666; border-bottom: 1px solid #666; } } blockquote { color: #666; margin: 0; padding: 1px 1em; border-left: .5em solid #eee; } hr, .footnotes::before { border: 1px dashed #ddd; } .frontmatter { text-align: center; } #TOC { a { text-decoration: none; } ul { list-style: none; padding-left: 1em; } & > ul { padding: 0; } ul ul { border-left: 1px solid lightsteelblue; } } .body h2 { border-bottom: 1px solid #666; } .body .appendix, .appendix ~ h2 { border-bottom-style: dashed; } .main-number::after { content: "."; } span[class^="ref-number-"] { font-weight: bold; } .ref-number-fig::after, .ref-number-tab::after { content: ":"; } .cross-ref-chp::before { content: "Chapter "; } .cross-ref-sec::before { content: "Section "; } .cross-ref-apd::before { content: "Appendix "; } .cross-ref-fig::before, .ref-number-fig::before { content: "Figure "; } .cross-ref-tab::before, .ref-number-tab::before { content: "Table "; } .cross-ref-eqn::before, .MathJax_ref:has(mjx-mtext > mjx-c + mjx-c)::before { content: "Equation "; } .abstract, #refs { &::before { display: block; margin: 1em auto; font-weight: bold; } } .abstract::before { content: "Abstract"; text-align: center; } #refs::before { content: "Bibliography"; font-size: 1.5em; } .ref-paren-open::before { content: "("; } .ref-paren-close::after { content: ")"; } .ref-semicolon::after { content: "; "; } .ref-and::after { content: " and "; } .ref-et-al::after { content: " et al."; font-style: italic; } .footnote-ref a { &::before { content: "["; } &::after { content: "]"; } } section.footnotes { margin-top: 2em; &::before { content: ""; display: block; max-width: 20em; } } .fade { background: repeating-linear-gradient(135deg, white, white 30px, #ddd 32px, #ddd 32px); opacity: 0.6; } @media print { body { max-width: 100%; } tr, img { break-inside: avoid; } } @media only screen and (min-width: 992px) { body:not(.pagesjs) pre:has(.line-numbers):not(:hover) { white-space: pre; } }
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
css/docco-classic.css
CSS
/* Derived from the Docco package by Jeremy Ashkenas: https://github.com/jashkenas/docco/ */ body { font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif; line-height: 1.5; color: #30404f; margin: 0; padding: 0; } h1, h2, h3, h4, h5, h6 { color: #112233; font-weight: normal; margin: 0 0 1rem 0; } .frontmatter { text-align: center; margin-top: 2em; } a { color: #0088cc; text-decoration: none; } a:hover, a:focus{ color: #005580; text-decoration: underline; } table { width: 100%; border: 0; } td.docs, td.code { vertical-align: top; padding: 1em 1em 1px 2em; } td.docs { width: 50%; } td.code{ background: #f5f5ff; overflow-x: hidden; } code{ font-size: .9em; } td.docs code{ background: #f8f8ff; border: 1px solid #dedede; } img { max-width: 100%; } pre code{ display: block; white-space: pre-wrap; } .pilwrap { position: relative; } .pilcrow { font: 12px Arial; text-decoration: none; color: rgb(69, 69, 69); position: absolute; top: 3px; left: -1.5em; padding: 1px 2px; opacity: 0; } td.docs:hover .pilcrow { opacity: 1; } blockquote { border-left: 4px solid #DDD; padding: 0 1em; color: #777; } .container { position: relative; } .handler{ width: 5px; padding: 0; cursor: col-resize; position: absolute; z-index: 5; }
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
css/faq.css
CSS
.faq-button { cursor: pointer; float: right; margin-left: 1em; } .faq-list { & > li { border: 1px solid #eee; padding: .5em; & > :first-child { display: block; cursor: pointer; background: #fafafa; margin: -.5em; padding: .5em; } } & > :not(.faq-clicked) > * { display: none; } .anchor { &:not(:hover > *) { display: none; } & > a::before { content: "#"; } } }
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
css/heading-anchor.css
CSS
.anchor { &:not(:hover > *) { display: none; } & > a::before { content: "#"; } }
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
css/key-buttons.css
CSS
kbd { border: 2px solid #ccc; box-shadow: 2px 2px #999; display: inline-block; padding: 0 5px; border-radius: 0.25em; min-width: 1.5em; text-align: center; margin-right: .15em; } kbd:hover { position: relative; top: 2px; left: 2px; }
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
css/manual.css
CSS
/* mainly for litedown::pkg_manual() */ .table-full, h3[id^="sec:arguments"] + table { width: 100%; td { vertical-align: baseline; & > p { &:first-child { margin-top: 0; } &:last-child { margin-bottom: 0; } } } } dt { font-weight: bold; } .side .pkg-desc dd { margin: 0 0 .5em; } code.fade::before { content: "🚫"; float: right; font-size: 1.5em; line-height: 1; } @media only screen { body:not(.pagesjs) pre:not([class]) { max-height: 300px; overflow-y: auto; } } .orcid { width: 1em; height: 1em; vertical-align: middle; }
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
css/pages.css
CSS
:root { --paper-width: 210mm; --paper-height: 297mm; --paper-margin-top: 40px; --paper-margin-right: 80px; --paper-margin-bottom: 40px; --paper-margin-left: 80px; --page-header-height: 40px; --page-header-bottom: 40px; --page-footer-height: 40px; --page-footer-top: 40px; } @page { size: var(--paper-width) var(--paper-height); margin: 0; } @page multiple { margin-top: var(--paper-margin-top); margin-bottom: var(--paper-margin-bottom); } .page-multiple { page: multiple; } .pagesjs { padding: 0; max-width: 100%; margin: 5mm; display: flex; justify-content: center; flex-wrap: wrap; gap: 5mm; .frontmatter, .chapter { min-height: unset; box-shadow: none; } & > *, &:not(:has(.frontmatter)):has(.chapter-toc) #TOC:not(.chapter-toc) { display: none; } .pagesjs-page { width: var(--paper-width); height: var(--paper-height); padding: var(--paper-margin-top) var(--paper-margin-right) var(--paper-margin-bottom) var(--paper-margin-left); break-after: page; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; img { max-width: 100%; } .chapter-before, .chapter-after, .buttons:has(+ .chapter-before) { display: none; } #TOC { border: none; padding: 0; margin-left: auto; &:not(.chapter-toc):is(.fragment-first, :not(.pagesjs-fragmented))::before { content: "Contents"; display: block; font-weight: bold; font-size: 1.5em; margin-bottom: 1em; } & > ul { columns: 18em; } a { display: flex; &::after { content: attr(data-page-number); align-self: end; margin-left: 1ch; } .section-number { margin-right: .3em; } .toc-text { position: relative; flex: 1 0; overflow: hidden; &::after { content: ""; width: 100%; position: absolute; bottom: 1.5ex; margin-left: 1ch; border-bottom: dashed 1px; } } } } & > .pagesjs-body > .pagesjs-fragmented { &:not(.fragment-first) { &, & .pagesjs-fragmented { border-top: none; & > thead { opacity: .5; } } } &:not(.fragment-last) { &, & .pagesjs-fragmented { border-bottom: none; & > tfoot { opacity: .5; } } } } .fullwidth { float: none; max-width: none; width: var(--paper-width); margin-left: calc(0px - var(--paper-margin-left)); transform: none; } .footnotes::before { content: ""; display: block; max-width: 20em; border-top: solid 1px; } &:has(.side-left, .embed-left) .pagesjs-body { padding-left: calc(0px - var(--side-margin)); .fullwidth { transform: translate(var(--side-margin)); } } &:has(.side-right, .embed-right) .pagesjs-body { padding-right: calc(0px - var(--side-margin)); } .side { font-size: .9em; background: none; } } } .pagesjs-header, .pagesjs-footer { font-size: .9em; display: flex; justify-content: space-between; } .pagesjs-header { flex: 0 0 var(--page-header-height); margin-bottom: var(--page-header-bottom); align-items: end; &::before { content: attr(data-main-title); } &::after { content: attr(data-page-title); } } .pagesjs-footer { flex: 0 0 var(--page-footer-height); margin-top: var(--page-footer-top); align-items: start; &::before { content: " "; } &::after { content: attr(data-page-number); } } .pagesjs-body { flex-grow: 1; position: relative; } @media only screen { .pagesjs { &:has(.pagesjs-page) { background: #f7f7f7; } .pagesjs-page { background: white; } .page-multiple { overflow-y: auto; } } .pagesjs-filling { display: block; .pagesjs-page { height: auto; .pagesjs-body:has(.footnotes) { margin-bottom: 1em; .footnotes { float: left; width: 100%; } } } } } @media print { .pagesjs { margin: 0; gap: 0; .page-multiple { padding-top: 0; padding-bottom: 0; height: auto; } } }
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
css/prism-xcode.css
CSS
/** * Prism.s theme ported from highlight.js's xcode style */ .token { &.comment { color: #007400; } &.punctuation { color: #999; } &.tag, &.selector { color: #aa0d91; } &.boolean, &.number, &.constant, &.symbol { color: #1c00cf; } &.property, &.attr-name, &.string, &.char, &.builtin { color: #c41a16; } &.inserted { background: #ccffd8; } &.deleted { background: #ffebe9; } &.operator, &.entity, &.url, .language-css &.string, .style &.string { color: #9a6e3a; } &.atrule, &.attr-value, &.keyword { color: #836c28; } &.function, &.class-name { color: #DD4A68; } &.regex, &.important, &.variable { color: #5c2699; } &.important, &.bold { font-weight: bold; } &.italic { font-style: italic; } }
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
css/site.css
CSS
nav > p:last-child { border-bottom: 1px dashed #666; } footer { border-top: 1px dashed #666; margin-top: 2em; .flex-col { gap: 2em; } } nav a, footer a { text-decoration: none; } nav a { display: inline-block; background: white; padding: .2em .5em; margin-right: .5em; } nav a:hover { background: #4682b4; color: white; } .body, .frontmatter, .body ~ .appendix { box-shadow: none; margin-top: auto; } .frontmatter { background: linear-gradient(0, white, aliceblue); } .body ~ .appendix { background: linear-gradient(0, whitesmoke, white); }
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
css/snap.css
CSS
:root { --slide-width: 100%; } html { scroll-snap-type: y mandatory; } th, td { padding: .2em .5em; } .slide { padding: 0 1em; background-color: #fff; } .slide, :is(.frontmatter, .middle) .main { display: flex; flex-direction: column; } .slide { & > .main { flex-grow: 1; } & > .header { margin-bottom: 1em; } h2, h3 { margin-top: unset; } } body { max-width: fit-content; padding: 0; } a { color: #eb4a47; } :not(pre) > code { background: #fdfded; } #TOC { columns: 2; &::before { font-size: 1.3em; font-weight: bold; display: block; border-bottom: 1px solid #666; } } :is(.frontmatter, .middle) .main { justify-content: center; } .footer { display: flex; justify-content: space-between; opacity: .5; font: .7em monospace; } .inverse { background: #eee; filter: invert(1); } .center { text-align: center; } .slide-container h2 .section-number { display: inline-block; background: #666; color: white; padding: 0 .1em; margin-right: .3em; } .overview { font-size: .8em; .slide-container { display: flex; flex-wrap: wrap; justify-content: space-evenly; .slide { width: var(--slide-width); border: 1px dotted #ccc; margin-bottom: 0.5em; } } } .mirrored { transform: scale(-1, 1); } .timer { opacity: 0; } html:fullscreen::-webkit-scrollbar, .spacer { display: none; } html:fullscreen { -ms-overflow-style: none; scrollbar-width: none; } @media screen and (min-width: 992px) { :root { --slide-width: 49%; --slide-scale: 1; --slide-ratio: 0.75; --slide-top: auto; } .slide-mode { font-size: 2em; background: #d7d8d2; scale: var(--slide-scale); margin-top: var(--slide-top); .slide { min-height: calc(100vh / var(--slide-scale)); width: calc(100vh / var(--slide-ratio) / var(--slide-scale)); box-shadow: 0 0 2em #888; clip-path: inset(0 -2em 0 -2em); scroll-snap-align: start; } .spacer { display: block; } .timer { opacity: initial; } } li li { font-size: .9em; } } @media (min-width: 1400px) { :root { --slide-width: 33%; } } @media (min-width: 1800px) { :root { --slide-width: 24.67%; } }
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
css/tabsets.css
CSS
.tabset { &:has(.tab-link) { margin-top: 1em; margin-bottom: 1em; } &:is(.tabset *) { margin: .5em auto; } } .tab-link, .tab-pane { border: 1px solid rgba(0, 0, 0, .05); border-radius: 5px 5px 0 0; padding: .2em .5em; &.active { border-color: rgba(0, 0, 0, .5); } } .tab-link { display: inline-block; margin: 0 .5em -1px 0; cursor: pointer; &.active { border-bottom-color: white; } & + .tab-pane.active { border-radius: 0 5px 0 0; } &:not(.active):hover { background: rgba(0, 0, 0, .05); } } .tab-pane { display: none; &.active { display: block; } }
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
js/alt-title.js
JavaScript
[...document.getElementsByTagName('img')].forEach(el => { if (el.alt) { el.alt = el.alt.replace(/\n/g, ' '); if (!el.title) el.title = el.alt; } });
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
js/appendix.js
JavaScript
// find <h[1-6] class="appendix"> and either add the class 'appendix' to // wrappers of appendix elements or create a new <div> next to the parent // element to hold all appendix elements (d => { const h = d.querySelector([1, 2, 3, 4, 5, 6].map(i => `h${i}.appendix`).join(',')); if (!h) return; h.classList.remove('appendix'); // test if two elements have same tag and class function sameClass(e1, e2) { return e1 && e2 && e1.tagName === e2.tagName && e1.className === e2.className; } // if h is in a wrapper whose prev/next sibling has the same class, simply add class to wrappers const p1 = h.parentNode, p0 = p1.previousElementSibling; let has_wrapper = sameClass(p1, p0), h0 = h, p2 = p1; // if has_wrapper == false, check if there's any sibling heading before h if (!has_wrapper) while (true) { h0 = h0.previousElementSibling; if (!h0) break; // if a heading is found, assume the appendix needs a new wrapper has_wrapper = !/^H[1-6]/.test(h0.tagName); if (!has_wrapper) break; // heading found, appendix doesn't have wrapper } while (p1) { p2 = p2.nextElementSibling; if (!sameClass(p1, p2)) break; p2.classList.add('appendix'); has_wrapper = true; } if (has_wrapper) { p1.classList.add('appendix'); return; } // create a new div instead const a = d.createElement('div'); a.className = 'appendix'; a.append(h.cloneNode(true)); while(h.nextSibling) { a.append(h.nextSibling); } h.parentNode.tagName === 'BODY' ? d.body.append(a) : h.parentNode.after(a); h.remove(); })(document);
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
js/callout.js
JavaScript
// turn <div class="callout-*"> to <fieldset><legend>* document.querySelectorAll('div[class^="callout-"]').forEach(el => { const f = document.createElement('fieldset'); f.className = el.className; f.classList.add('callout'); // if the data-legend attribute exists, use its value as legend, otherwise use the class name f.insertAdjacentHTML('afterbegin', '<legend></legend>'); f.firstChild.dataset.legend = el.dataset.legend || el.classList[0].replace('callout-', '').replace('-', ' '); el.after(f); f.append(...el.children); el.remove(); });
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
js/center-img.js
JavaScript
(d => { function one_child(el) { if (el.childElementCount !== 1) return false; const nodes = el.childNodes; if (nodes.length === 1) return true; for (let i in nodes) { let node = nodes[i]; if (node.nodeName === '#text' && !/^\s$/.test(node.textContent)) return false; } return true; } function center_el(tagName) { d.querySelectorAll(tagName).forEach(tag => { let parent = tag.parentElement; // center an image if it is the only element of its parent if (one_child(parent)) { // if there is a link on image, check grandparent const parentA = parent.nodeName === 'A'; if (parentA) { parent = parent.parentElement; if (!one_child(parent)) return; parent.firstElementChild.style.border = 'none'; } if (parent.nodeName === 'P') { parent.style.textAlign = 'center'; if (!parentA && tagName === 'img' && !/^data:/.test(tag.src)) { parent.innerHTML = `<a href="${tag.src}" style="border: none;">${tag.outerHTML}</a>`; } } } }); } ['img', 'embed', 'object'].forEach(center_el); // also center paragraphs that contain `* * *` d.querySelectorAll('p').forEach(p => { if (p.innerText === '* * *') p.style.textAlign = 'center'; }); })(document);
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
js/chapter-toc.js
JavaScript
// copy chapter TOC to each chapter's first page (under h1) (d => { d.querySelector('.chapter-toc') || d.querySelectorAll('#TOC > ul > li > a[href^="#"]').forEach(a => { const id = a.getAttribute('href'), h = d.getElementById(id.replace(/^#/, '')); if (h?.tagName !== 'H1') return; const h2 = h.nextElementSibling; if (h2?.tagName === 'H1') return; const u = a.nextElementSibling; if (u?.tagName === 'UL') { const toc = d.createElement('div'); toc.className = 'chapter-toc'; toc.id = 'TOC'; toc.append(u.cloneNode(true)); toc.firstChild.className = a.parentNode.parentNode.className; (h2?.classList.contains('epigraph') ? h2 : h).after(toc); } }); })(document);
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
js/code-lang.js
JavaScript
// add 'language-' prefix to <code> inside <pre> for syntax highlighters to work (e.g., prism.js) document.querySelectorAll('pre').forEach(pre => { const code = pre.querySelector('code'); // no code or already highlighted if (!code || code.querySelector('span')) return; const c1 = pre.className, c2 = code.className, r = /^lang(uage)?-/; // at least one of pre or code must have className, which shouldn't start with lang prefix if (!(c1 || c2) || r.test(c1) || r.test(c2)) return; code.className = 'language-' + (c2 || c1); });
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
js/code-line-numbers.js
JavaScript
// add line numbers to code blocks for <code class="line-numbers" [data-start=*]> (() => { function addNum(el) { const s = '<span data-line-number=""></span>', sel = 'span[data-line-number]'; if (el.querySelector(sel)) return; el.innerHTML = s + el.innerHTML.replace(/\n(?=.|\s)/g, '\n' + s); let n1 = +el.dataset.start; if (isNaN(n1)) n1 = 1; const spans = el.querySelectorAll(sel), w = ('' + (n1 - 1 + spans.length)).length; spans.forEach(sp => { let n = '' + (n1++), d = w - n.length; if (d > 0) n = '0'.repeat(d) + n; sp.dataset.lineNumber = n; }); } addEventListener('load', e => document.querySelectorAll('pre > code.line-numbers:first-child').forEach(addNum)); })();
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
js/comment-utils.js
JavaScript
(function(d) { function inIFrame() { let iframe = true; try { iframe = window.self !== window.top; } catch (e) {} return iframe; }; const a = d.querySelector('section.comments'); if (!a) return; // remove the comments section when in iframe (e.g., in RStudio Viewer) if (inIFrame()) { a.remove(); return; } // scroll to the comments section when URL contains a hash #comment-... location.hash.match(/^#comment-[0-9]+$/) && a.scrollIntoView(); // create a new script and change attribute 'data-src' to 'src' (to actually load the script) const s = a.querySelector('script[data-src]'); if (!s) return; const r = s.dataset.src, s2 = d.createElement('script'); [...s.attributes].forEach(b => { s2.setAttribute(b.name, b.value); }); s2.src = r; s.remove(); a.appendChild(s2); })(document);
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
js/copy-button.js
JavaScript
// add a button to elements to copy their content: https://yihui.org/en/2023/09/copy-button/ (d => { const cfg = d.currentScript?.dataset; d.querySelectorAll(cfg?.selector || 'pre>code, .copy-this').forEach(el => { const btn = d.createElement('span'), cls = btn.classList, c1 = 'copy-success', c2 = 'copy-fail', pre = el.parentNode, is_code = el.tagName === 'CODE' && pre?.tagName === 'PRE'; btn.className = 'copy-button'; // temporarily add a class to the button (as a feedback to copy action) function feedback(c) { cls.add(c); setTimeout(() => cls.remove(c), 1000); } // for code.code-fence in div.fenced-chunk (from litedown), copy the whole chunk's source function getText() { return (is_code && el.classList.contains('code-fence') && pre.parentNode?.classList.contains('fenced-chunk')) ? [...pre.parentNode.querySelectorAll('code[class]')] .map(code => code.innerText.replace(/\n$/, '')).join('\n') : el.innerText; } btn.onclick = () => navigator.clipboard.writeText(getText()).then( () => feedback(c1), () => feedback(c2) ); // add the button to <pre> for <code> because <code>'s innerHTML' may be // changed later, e.g., by syntax highlighting libraries const p = is_code ? pre : el; // add the button only if it has not been added p.querySelector('.copy-button') || p.append(btn); p.hasAttribute('tabIndex') || (p.tabIndex = '0'); getComputedStyle(p).position === 'static' && (p.style.position = 'relative'); }); })(document);
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
js/custom-disqus.js
JavaScript
// lazyload Disqus on my personal site (function(d) { var inIFrame = function() { var iframe = true; try { iframe = window.self !== window.top; } catch (e) {} return iframe; }; if (inIFrame()) return; var t = d.getElementById('disqus_thread'), s = t.nextElementSibling, a = d.querySelector('section.comments'), rads = a.querySelectorAll('input[type="radio"]'); s.setAttribute('data-timestamp', +new Date()); var inputValues = function() { var v = {}; rads.forEach(function(el) { v[el.id] = el.checked; }); return v; }, selectTab2 = function() { a.querySelector('#tab-2').checked = true; return 'add'; }, showFullComment = function(el) { if (el.name !== 'layout') return; a.classList[el.id === 'layout-2' ? selectTab2() : 'remove']('comment-full'); }, inputRestore = function() { var v = localStorage.getItem('comment-prefs'); if (!v) return; v = JSON.parse(v); rads.forEach(function(el) { if (v[el.id]) { el.checked = true; showFullComment(el); } }); }, inputSave = function() { showFullComment(this); loadScript(); var v = JSON.stringify(inputValues()); try { localStorage.setItem('comment-prefs', v); } catch (e) {} }, loadScript = function() { var full = a.classList.contains('comment-full'); a.querySelectorAll('input[name="tabs"]').forEach(function(el, i) { if (!full && !el.checked) return; var p = a.querySelector('.panel:nth-of-type(' + (i + 1) + ') > script[data-src]'); if (!p || !p.dataset.src) return; p.src = p.dataset.src; p.removeAttribute('data-src'); }); }; // restore radio button values when opening page inputRestore(); // save when radio button values change rads.forEach(function(el) { el.addEventListener('change', inputSave); }); var b = false, l = function(scroll) { if (b) return; a.querySelector('.tabs').style.display = ''; loadScript(); b = true; if (scroll) t.scrollIntoView(); } s.onerror = function(e) { // try to load Disqus in the read-only mode var s2 = d.createElement('script'); s2.src = "//cdn.jsdelivr.net/gh/yihui/DisqusJS@1.3.3/src/disqus.min.js"; t.appendChild(s2); try { localStorage.setItem('dsqjs_mode', 'dsqjs'); } catch (e) {} s2.onload = function(e) { var s3 = d.createElement('link'); s3.rel = 'stylesheet'; s3.href = '//cdn.jsdelivr.net/gh/yihui/DisqusJS@1.3.3/src/disqusjs.min.css'; d.head.appendChild(s3); disqus_config.DisqusJSInit(); }; s2.onerror = function(e) { t.innerText = 'Sorry, but you cannot make comments because Disqus failed to load for some reason. It is known to be blocked in certain regions. If you are sure it is not blocked in your region, please refresh the page. Alternatively, you can comment with Utterances. 您可能需要翻墙发表 Disqus 评论;若没有梯子,不妨尝试使用 Github 登录 Utterances 评论。'; t.style.border = '1px dashed'; t.style.padding = '.5em'; t.style.background = 'lightyellow'; selectTab2(); }; }; s.onload = function(e) { // if Disqus comment count is zero, just get rid of the Disqus tab var dc = d.getElementById('disqus_count'); if (!dc) return; var s3 = d.createElement('script'); s3.src = '//yihui.disqus.com/count.js'; s3.id = 'dsq-count-scr'; t.appendChild(s3); new MutationObserver(() => { if (dc.innerText == '' || dc.innerText > 0) return; selectTab2(); loadScript(); a.append(a.querySelector('#tab-2 ~ .panel')); a.querySelector('.tabs').remove(); a.querySelector('.panel').style.display = 'block'; }).observe(dc, {characterData: true, childList: true}); }; // show comments when the hash means to jump to a comment if (location.hash.match(/^#comment-[0-9]+$/)) return l(true); var c = function() { if (b) return; var rect = a.getBoundingClientRect(); if (rect.top < window.innerHeight && rect.bottom >= 0) l(); }; window.addEventListener('load', c); d.addEventListener('scroll', c); })(document);
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
js/dl-fieldset.js
JavaScript
// convert <dl><dt>Title</dt><dd>Content</dd></dl> // to <fieldset><legend>Title</legend>Content</fieldset>; // see documentation at: https://yihui.org/en/2023/11/dl-fieldset/ document.querySelectorAll('dl').forEach(dl => { if (dl.childElementCount !== 2) return; const dt = dl.children[0], dd = dl.children[1]; if (dt.tagName !== 'DT' || dd.tagName !== 'DD') return; dt.outerHTML = dt.outerHTML.replace(/^<dt(>[\s\S]*<\/)dt>$/, '<legend$1legend>'); dd.outerHTML = dd.innerHTML; dl.outerHTML = dl.outerHTML.replace(/^<dl(>[\s\S]*<\/)dl>$/, '<fieldset$1fieldset>'); });
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
js/docco-classic.js
JavaScript
// create a <table> of 2 columns; put <pre> in the right column and other elements in the left column (d => { // find the first <pre> and assume it to be the container all code blocks const c1 = d.querySelector('pre')?.parentNode; if (!c1) return; c1.insertAdjacentHTML('afterend', '<div class="container"><div class="handler"></div><table><tbody><tr><td class="docs"><div class="pilwrap"><a class="pilcrow" href="#">&para;</a></div></td><td class="code"></td></tr></tbody></table></div>'); // move <pre> into <tbody>'s second <td>, and everything else into first <td> const c2 = c1.nextElementSibling.querySelector('tbody'); let c3 = c2.lastElementChild, c4 = c3.cloneNode(true), newRow = false; while (true) { const el = c1.firstElementChild; if (!el) break; if (el.tagName === 'PRE') { c3.lastElementChild.append(el); newRow = true; } else { if (newRow) { c3 = c4.cloneNode(true); c2.append(c3); newRow = false; } c3.firstElementChild.append(el); } } c1.remove(); // if a cell contains plots, shift all code cells from there down by one row for (let row of c2.rows) { if (row.querySelector('td.docs img')) { let prev = row.previousElementSibling; if (!prev) continue; // create a new row if necessary if (c2.lastElementChild.cells[1].innerText !== '') { c2.append(c4.cloneNode(true)); } // move the last empty code cell before the previous code cell prev.cells[0].after(c2.lastElementChild.cells[1]); while (prev) { const cells = prev.nextElementSibling?.cells; if (!cells) break; cells[0].after(prev.lastElementChild); prev = prev.nextElementSibling; } break; } } [...c2.rows].forEach((row, i) => { row.id = 'row' + (i + 1); row.querySelector('.pilcrow').href = '#' + row.id; }); })(document);
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
js/docco-resize.js
JavaScript
jQuery.fn.disableTextSelect=function(){return this.each(function(){$(this).css({MozUserSelect:"none",webkitUserSelect:"none"}).attr("unselectable","on").bind("selectstart",function(){return false})})};jQuery.fn.enableTextSelect=function(){return this.each(function(){$(this).css({MozUserSelect:"",webkitUserSelect:""}).attr("unselectable","off").unbind("selectstart")})};$(document).ready(function(){var e=$("td.docs");var t=$("td.code");var n=$("div.handler");n.css("height",$("table").css("height"));n.css("left",t.offset().left);var r=parseInt(e.css("padding-right"));var i=parseInt(e.css("padding-left"));var s=parseInt(n.css("width"));n.mousedown(function(){$("body").disableTextSelect();$(document).bind("mousemove",function(o){var u=o.pageX-e.offset().left-r-i-.5*s;e.width(u);n.css("left",t.offset().left)}).mouseup(function(){$("body").enableTextSelect();$(document).unbind("mousemove")})});var o="both";$(document).keydown(function(r){if(r.which==84){switch(o){case"both":t.hide(500);n.hide();o="left";break;case"left":t.show(500);e.hide(500);o="right";break;case"right":t.show(500);e.show(500);n.show(500);o="both";break;default:break}}})});
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
js/external-link.js
JavaScript
(d => { const r = /^(https?:)?\/\//; d.querySelectorAll('a').forEach(a => { if (!a.title) a.title = decodeURI(a.href); if (!r.test(a.getAttribute('href'))) return; // add _blank target to external links a.target = '_blank'; // shorten bare links if (a.childElementCount === 0 && r.test(a.innerText)) { a.innerText = a.innerText.replace(r, '').replace(/(.+)#.*$/, '$1'); } }); })(document);
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
js/faq.js
JavaScript
(d => { const cls_list = 'faq-list', cls_clicked = 'faq-clicked'; function faq(el, id) { // each child of the list must have at least 2 child elements (one question // and one answer) const lis = el.children; if (lis.length === 0) return; for (let li of lis) { if (li.childElementCount < 2) return; } let ls = el.classList; if (ls.length > 0 && !ls.contains(cls_list)) return; ls.add(cls_list); // a button to collapse/expand all FAQs const btn = d.createElement('span'); let status = false; btn.className = 'faq-button'; btn.innerText = '⊕'; btn.onclick = function() { status = !status; this.innerText = status ? '⊖' : '⊕'; for (const li of el.children) { li.classList.toggle(cls_clicked, status); } }; el.before(btn); // add anchor links after questions for (let i = 0; i < lis.length; i++) { let li = lis[i]; li.id = 'faq-' + (id ? id + '-' : '') + (i + 1); let p = li.firstElementChild; p.insertAdjacentHTML('beforeend', ` <span class="anchor"><a href="#${li.id}"></a></span>`); if (location.hash === '#' + li.id) { li.scrollIntoView(); li.classList.add(cls_clicked); } p.onclick = function(e) { li.classList.toggle(cls_clicked); }; } } // ignore lists in footnotes, and lists must be direct child of some // block-level elements such as <div> const ols = d.querySelectorAll(['div', 'main', 'section', 'article'].map( (x) => x + ':not(.footnotes) > ol' ).join(',')); for (let i = 0; i < ols.length; i++) { let ol = ols[i]; faq(ol, ols.length > 1 ? i + 1 : 0); } })(document);
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
js/fix-footnote.js
JavaScript
(d => { // add [] to footnote numbers d.querySelectorAll('sup[id^="fnref:"] > a.footnote-ref, a.footnote-ref > sup').forEach(el => { if (!/^[0-9]+$/.test(el.innerText)) return; el.innerText = `[${el.innerText}]`; el.parentNode.before(d.createTextNode(' ')); }); // move the return symbol into the previous <p> d.querySelectorAll('.footnotes > ol > li > p ~ .footnote-return').forEach(el => { el.previousElementSibling.lastChild.after(el); }); })(document);
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck
js/fix-pandoc.js
JavaScript
// move the class from <pre class="foo"> (generated by Pandoc with --no-highlight) // to <code class="language-foo"> so that Prism.js can highlight the code document.querySelectorAll('pre[class]:not([class^=language-])').forEach(el => { el.firstElementChild?.classList.add(`language-${el.classList[0]}`); el.removeAttribute('class'); }); document.querySelectorAll('table').forEach(el => { el.getAttribute('style') === 'width:100%;' && el.removeAttribute('style'); el.querySelector('colgroup')?.remove(); });
yihui/lite.js
19
Miscellaneous lightweight tools and utilities in JavaScript
JavaScript
yihui
Yihui Xie
rstudio swissre merck