Browse Source

twitter card htmldocument

master
boB Rudis 5 years ago
parent
commit
0e31002903
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 1
      .Rbuildignore
  2. 16
      DESCRIPTION
  3. 2
      LICENSE
  4. 21
      LICENSE.md
  5. 1
      NAMESPACE
  6. 46
      R/twitter-doc.R
  7. 43
      README.Rmd
  8. 47
      README.md
  9. 668
      inst/rmarkdown/templates/twittercard/default.html
  10. 11
      inst/rmarkdown/templates/twittercard/skeleton/skeleton.Rmd
  11. 4
      inst/rmarkdown/templates/twittercard/template.yaml
  12. 117
      man/twitter_document.Rd

1
.Rbuildignore

@ -15,3 +15,4 @@
^tmp$
^notes$
^\.gitlab-ci\.yml$
^LICENSE\.md$

16
DESCRIPTION

@ -1,25 +1,23 @@
Package: widgetcard
Type: Package
Title: Tools to Enable Easier Content Embedding in Tweets
Version: 0.1.1
Date: 2019-04-04
Version: 0.2.0
Date: 2019-08-14
Authors@R: c(
person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-5670-2640"))
)
Maintainer: Bob Rudis <bob@rud.is>
Description: Tools to enable rasier content embedding in tweets.
Description: Tools to enable easier content embedding in tweets.
URL: https://gitlab.com/hrbrmstr/widgetcard
BugReports: https://gitlab.com/hrbrmstr/widgetcard/issues
Encoding: UTF-8
License: AGPL
License: MIT + file LICENSE
Suggests:
ssh,
plotly,
testthat,
covr,
knitr,
rmarkdown
covr
Depends:
R (>= 3.2.0)
Imports:
@ -28,7 +26,9 @@ Imports:
widgetframe,
ggplot2,
shiny,
jsonlite
jsonlite,
knitr,
rmarkdown
Roxygen: list(markdown = TRUE)
RoxygenNote: 6.1.1
VignetteBuilder: knitr

2
LICENSE

@ -0,0 +1,2 @@
YEAR: 2019
COPYRIGHT HOLDER: Bob Rudis

21
LICENSE.md

@ -0,0 +1,21 @@
# MIT License
Copyright (c) 2019 Bob Rudis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

1
NAMESPACE

@ -2,6 +2,7 @@
export(card_widget)
export(gg_preview)
export(twitter_document)
import(htmltools)
import(htmlwidgets)
import(widgetframe)

46
R/twitter-doc.R

@ -0,0 +1,46 @@
#' Standard HTML Document with Twitter Tags
#'
#' @inheritParams rmarkdown::html_document
#' @export
twitter_document <- function (
toc = FALSE, toc_depth = 3, toc_float = FALSE, number_sections = FALSE,
section_divs = TRUE, fig_width = 7, fig_height = 5, fig_retina = 2,
fig_caption = TRUE, dev = "png", df_print = "default",
code_folding = c("none", "show", "hide"), code_download = FALSE, smart = TRUE,
self_contained = TRUE, theme = "default", highlight = "default",
mathjax = "default", extra_dependencies = NULL,
css = NULL, includes = NULL, keep_md = FALSE, lib_dir = NULL,
md_extensions = NULL, pandoc_args = NULL, ...) {
rmarkdown::html_document(
template = system.file('rmarkdown/templates/twittercard/default.html', package = 'widgetcard'),
toc = toc,
toc_depth = toc_depth,
toc_float = toc_float,
number_sections = number_sections,
section_divs = section_divs,
fig_width = fig_width,
fig_height = fig_height,
fig_retina = fig_retina,
fig_caption = fig_caption,
dev = dev,
df_print = df_print,
code_folding = code_folding,
code_download = code_download,
smart = smart,
self_contained = self_contained,
theme = theme,
highlight = highlight,
mathjax = mathjax,
extra_dependencies = extra_dependencies,
css = css,
includes = includes,
keep_md = keep_md,
lib_dir = lib_dir,
md_extensions = md_extensions,
pandoc_args = pandoc_args,
...
)
}

43
README.Rmd

@ -1,42 +1,32 @@
---
output: rmarkdown::github_document
editor_options:
chunk_output_type: inline
output:
rmarkdown::github_document:
df_print: kable
---
```{r pkg-knitr-opts, include=FALSE}
knitr::opts_chunk$set(collapse=TRUE, fig.retina=2, message=FALSE, warning=FALSE)
options(width=120)
hrbrpkghelpr::global_opts()
```
[![Travis-CI Build Status](https://travis-ci.org/hrbrmstr/widgetcard.svg?branch=master)](https://travis-ci.org/hrbrmstr/widgetcard)
[![Coverage Status](https://codecov.io/gh/hrbrmstr/widgetcard/branch/master/graph/badge.svg)](https://codecov.io/gh/hrbrmstr/widgetcard)
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/widgetcard)](https://cran.r-project.org/package=widgetcard)
# widgetcard
Tools to Enable Easier Content Embedding in Tweets
## Description
```{r badges, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::stinking_badges()
```
Tools to Enable Easier Content Embedding in Tweets
```{r description, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::yank_title_and_description()
```
## What's Inside The Tin
The following functions are implemented:
- `card_widget`: Turn an htmlwidget into a web deployable, interactive Twitter card
- `gg_preview`: Generate a Twitter Player card preview image from a ggplot2 plot
```{r ingredients, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::describe_ingredients()
```
## Installation
```{r install-ex, eval=FALSE}
install.packages("widgetcard", repos = "https://cinc.rud.is/")
# or
devtools::install_git("https://git.sr.ht/~hrbrmstr/widgetcard")
# or
devtools::install_gitlab("hrbrmstr/widgetcard")
# or (if you must)
devtools::install_github("hrbrmstr/widgetcard")
```{r install-ex, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::install_block()
```
## Usage
@ -51,5 +41,4 @@ cloc::cloc_pkg_md()
## Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md).
By participating in this project you agree to abide by its terms.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

47
README.md

@ -1,9 +1,18 @@
[![Travis-CI Build
[![Project Status: Active – The project has reached a stable, usable
state and is being actively
developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Signed
by](https://img.shields.io/badge/Keybase-Verified-brightgreen.svg)](https://keybase.io/hrbrmstr)
![Signed commit
%](https://img.shields.io/badge/Signed_Commits-87.5%25-lightgrey.svg)
[![Linux build
Status](https://travis-ci.org/hrbrmstr/widgetcard.svg?branch=master)](https://travis-ci.org/hrbrmstr/widgetcard)
[![Coverage
Status](https://codecov.io/gh/hrbrmstr/widgetcard/branch/master/graph/badge.svg)](https://codecov.io/gh/hrbrmstr/widgetcard)
[![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/widgetcard)](https://cran.r-project.org/package=widgetcard)
![Minimal R
Version](https://img.shields.io/badge/R%3E%3D-3.2.0-blue.svg)
![License](https://img.shields.io/badge/License-MIT-blue.svg)
# widgetcard
@ -11,7 +20,7 @@ Tools to Enable Easier Content Embedding in Tweets
## Description
Tools to Enable Easier Content Embedding in Tweets
Tools to enable easier content embedding in tweets.
## What’s Inside The Tin
@ -21,19 +30,27 @@ The following functions are implemented:
Twitter card
- `gg_preview`: Generate a Twitter Player card preview image from a
ggplot2 plot
- `twitter_document`: Standard HTML Document with Twitter Tags
## Installation
``` r
install.packages("widgetcard", repos = "https://cinc.rud.is/")
install.packages("widgetcard", repos = "https://cinc.rud.is")
# or
remotes::install_git("https://git.rud.is/hrbrmstr/widgetcard.git")
# or
remotes::install_git("https://git.sr.ht/~hrbrmstr/widgetcard")
# or
devtools::install_git("https://git.sr.ht/~hrbrmstr/widgetcard")
# or
devtools::install_gitlab("hrbrmstr/widgetcard")
# or (if you must)
devtools::install_github("hrbrmstr/widgetcard")
remotes::install_gitlab("hrbrmstr/widgetcard")
# or
remotes::install_bitbucket("hrbrmstr/widgetcard")
# or
remotes::install_github("hrbrmstr/widgetcard")
```
NOTE: To use the ‘remotes’ install options you will need to have the
[{remotes} package](https://github.com/r-lib/remotes) installed.
## Usage
See [the
@ -43,12 +60,12 @@ vignette](https://rud.is/dl/creating-interactive-player-cards.html).
| Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) |
| :--- | -------: | ---: | --: | ---: | ----------: | ---: | -------: | ---: |
| HTML | 1 | 0.09 | 370 | 0.47 | 31 | 0.20 | 1 | 0.00 |
| R | 7 | 0.64 | 327 | 0.41 | 66 | 0.42 | 168 | 0.48 |
| Rmd | 3 | 0.27 | 93 | 0.12 | 61 | 0.39 | 182 | 0.52 |
| HTML | 1 | 0.08 | 370 | 0.44 | 31 | 0.19 | 1 | 0.00 |
| R | 8 | 0.67 | 370 | 0.44 | 70 | 0.44 | 172 | 0.49 |
| Rmd | 3 | 0.25 | 92 | 0.11 | 58 | 0.36 | 175 | 0.50 |
## Code of Conduct
Please note that this project is released with a [Contributor Code of
Conduct](CONDUCT.md). By participating in this project you agree to
abide by its terms.
Please note that this project is released with a Contributor Code of
Conduct. By participating in this project you agree to abide by its
terms.

668
inst/rmarkdown/templates/twittercard/default.html

@ -0,0 +1,668 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"$if(lang)$ lang="$lang$" xml:lang="$lang$"$endif$>
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<!-- USING THE TWITTER TEMPLATE -->
$if(theme)$
$else$
<meta name="viewport" content="width=device-width, initial-scale=1">
$endif$
$for(author-meta)$
<meta name="author" content="$author-meta$" />
$endfor$
$if(date-meta)$
<meta name="date" content="$date-meta$" />
$endif$
$if(twitter-meta)$
TWITTER META
$endif$
$if(twitter)$
<meta name="twitter:card" content="summary_large_image" />
$if(twitter.site)$<meta name="twitter:site" content="$twitter.site$" />$endif$
$if(twitter.creator)$<meta name="twitter:creator" content="$twitter.creator$" />$endif$
$if(title)$<meta name="twitter:title" content="$title$" />$endif$
$if(twitter.description)$<meta name="twitter:description" content="$twitter.description$" />$endif$
$if(twitter.image)$<meta name="twitter:image" content="$twitter.image$" />$endif$
$endif$
<title>$if(title-prefix)$$title-prefix$ - $endif$$pagetitle$</title>
$for(header-includes)$
$header-includes$
$endfor$
$if(highlightjs)$
<style type="text/css">code{white-space: pre;}</style>
$if(theme)$
<style type="text/css">
pre:not([class]) {
background-color: white;
}
</style>
$endif$
<script type="text/javascript">
if (window.hljs) {
hljs.configure({languages: []});
hljs.initHighlightingOnLoad();
if (document.readyState && document.readyState === "complete") {
window.setTimeout(function() { hljs.initHighlighting(); }, 0);
}
}
</script>
$endif$
$if(highlighting-css)$
<style type="text/css">code{white-space: pre;}</style>
<style type="text/css" data-origin="pandoc">
$highlighting-css$
$if(code_folding)$
.sourceCode .row {
width: 100%;
}
.sourceCode {
overflow-x: auto;
}
.code-folding-btn {
margin-right: -30px;
}
$endif$
</style>
<script>
// apply pandoc div.sourceCode style to pre.sourceCode instead
(function() {
var sheets = document.styleSheets;
for (var i = 0; i < sheets.length; i++) {
if (sheets[i].ownerNode.dataset["origin"] !== "pandoc") continue;
try { var rules = sheets[i].cssRules; } catch (e) { continue; }
for (var j = 0; j < rules.length; j++) {
var rule = rules[j];
// check if there is a div.sourceCode rule
if (rule.type !== rule.STYLE_RULE || rule.selectorText !== "div.sourceCode") continue;
var style = rule.style.cssText;
// check if color or background-color is set
if (rule.style.color === '' && rule.style.backgroundColor === '') continue;
// replace div.sourceCode by a pre.sourceCode rule
sheets[i].deleteRule(j);
sheets[i].insertRule('pre.sourceCode{' + style + '}', j);
}
}
})();
</script>
$if(theme)$
<style type="text/css">
pre:not([class]) {
background-color: white;
}
</style>
$endif$
$endif$
$if(abstract)$
<style type="text/css">
p.abstract{
text-align: center;
font-weight: bold;
}
div.abstract{
margin: auto;
width: 90%;
}
</style>
$endif$
$if(theme)$
<style type="text/css">
h1 {
font-size: 34px;
}
h1.title {
font-size: 38px;
}
h2 {
font-size: 30px;
}
h3 {
font-size: 24px;
}
h4 {
font-size: 18px;
}
h5 {
font-size: 16px;
}
h6 {
font-size: 12px;
}
.table th:not([align]) {
text-align: left;
}
$if(source_embed)$
#rmd-source-code {
display: none;
}
$endif$
</style>
$endif$
$for(css)$
<link rel="stylesheet" href="$css$" $if(html5)$$else$type="text/css" $endif$/>
$endfor$
$if(theme)$
<style type = "text/css">
.main-container {
max-width: 940px;
margin-left: auto;
margin-right: auto;
}
code {
color: inherit;
background-color: rgba(0, 0, 0, 0.04);
}
img {
max-width:100%;
}
.tabbed-pane {
padding-top: 12px;
}
.html-widget {
margin-bottom: 20px;
}
button.code-folding-btn:focus {
outline: none;
}
summary {
display: list-item;
}
</style>
$if(kable-scroll)$
<style type="text/css">
.kable-table {
border: 1px solid #ccc;
border-radius: 4px;
overflow: auto;
padding-left: 8px;
padding-right: 8px;
margin-bottom: 20px;
max-height: 350px;
}
.kable-table table {
margin-bottom: 0px;
}
.kable-table table>thead>tr>th {
border: none;
border-bottom: 2px solid #dddddd;
}
.kable-table table>thead {
background-color: #fff;
}
</style>
$endif$
$if(navbar)$
<style type="text/css">
/* padding for bootstrap navbar */
body {
padding-top: $body_padding$px;
padding-bottom: 40px;
}
/* offset scroll position for anchor links (for fixed navbar) */
.section h1 {
padding-top: $header_padding$px;
margin-top: -$header_padding$px;
}
.section h2 {
padding-top: $header_padding$px;
margin-top: -$header_padding$px;
}
.section h3 {
padding-top: $header_padding$px;
margin-top: -$header_padding$px;
}
.section h4 {
padding-top: $header_padding$px;
margin-top: -$header_padding$px;
}
.section h5 {
padding-top: $header_padding$px;
margin-top: -$header_padding$px;
}
.section h6 {
padding-top: $header_padding$px;
margin-top: -$header_padding$px;
}
.dropdown-submenu {
position: relative;
}
.dropdown-submenu>.dropdown-menu {
top: 0;
left: 100%;
margin-top: -6px;
margin-left: -1px;
border-radius: 0 6px 6px 6px;
}
.dropdown-submenu:hover>.dropdown-menu {
display: block;
}
.dropdown-submenu>a:after {
display: block;
content: " ";
float: right;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
border-width: 5px 0 5px 5px;
border-left-color: #cccccc;
margin-top: 5px;
margin-right: -10px;
}
.dropdown-submenu:hover>a:after {
border-left-color: #ffffff;
}
.dropdown-submenu.pull-left {
float: none;
}
.dropdown-submenu.pull-left>.dropdown-menu {
left: -100%;
margin-left: 10px;
border-radius: 6px 0 6px 6px;
}
</style>
<script>
// manage active state of menu based on current page
$$(document).ready(function () {
// active menu anchor
href = window.location.pathname
href = href.substr(href.lastIndexOf('/') + 1)
if (href === "")
href = "index.html";
var menuAnchor = $$('a[href="' + href + '"]');
// mark it active
menuAnchor.parent().addClass('active');
// if it's got a parent navbar menu mark it active as well
menuAnchor.closest('li.dropdown').addClass('active');
});
</script>
$endif$
<!-- tabsets -->
<style type="text/css">
.tabset-dropdown > .nav-tabs {
display: inline-table;
max-height: 500px;
min-height: 44px;
overflow-y: auto;
background: white;
border: 1px solid #ddd;
border-radius: 4px;
}
.tabset-dropdown > .nav-tabs > li.active:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
content: "&#xe258;";
border: none;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs > li.active {
display: block;
}
.tabset-dropdown > .nav-tabs > li > a,
.tabset-dropdown > .nav-tabs > li > a:focus,
.tabset-dropdown > .nav-tabs > li > a:hover {
border: none;
display: inline-block;
border-radius: 4px;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li {
display: block;
float: none;
}
.tabset-dropdown > .nav-tabs > li {
display: none;
}
</style>
<!-- code folding -->
$if(code_menu)$
<style type="text/css">
.code-folding-btn { margin-bottom: 4px; }
</style>
$endif$
$if(toc_float)$
<style type="text/css">
#$idprefix$TOC {
margin: 25px 0px 20px 0px;
}
@media (max-width: 768px) {
#$idprefix$TOC {
position: relative;
width: 100%;
}
}
$if(toc_print)$
$else$
@media print {
#$idprefix$TOC {
display: none !important;
}
}
$endif$
.toc-content {
padding-left: 30px;
padding-right: 40px;
}
div.main-container {
max-width: 1200px;
}
div.tocify {
width: 20%;
max-width: 260px;
max-height: 85%;
}
@media (min-width: 768px) and (max-width: 991px) {
div.tocify {
width: 25%;
}
}
@media (max-width: 767px) {
div.tocify {
width: 100%;
max-width: none;
}
}
.tocify ul, .tocify li {
line-height: 20px;
}
.tocify-subheader .tocify-item {
font-size: 0.90em;
}
.tocify .list-group-item {
border-radius: 0px;
}
$if(toc_collapsed)$
$else$
.tocify-subheader {
display: inline;
}
.tocify-subheader .tocify-item {
font-size: 0.95em;
}
$endif$
</style>
$endif$
$endif$
</head>
<body>
$if(theme)$
<div class="container-fluid main-container">
$if(toc_float)$
<!-- setup 3col/9col grid for toc_float and main content -->
<div class="row-fluid">
<div class="col-xs-12 col-sm-4 col-md-3">
<div id="$idprefix$TOC" class="tocify">
</div>
</div>
<div class="toc-content col-xs-12 col-sm-8 col-md-9">
$endif$
$endif$
$for(include-before)$
$include-before$
$endfor$
$if(theme)$
<div class="fluid-row" id="$idprefix$header">
$if(code_menu)$
<div class="btn-group pull-right">
<button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span>Code</span> <span class="caret"></span></button>
<ul class="dropdown-menu" style="min-width: 50px;">
$if(code_folding)$
<li><a id="rmd-show-all-code" href="#">Show All Code</a></li>
<li><a id="rmd-hide-all-code" href="#">Hide All Code</a></li>
$if(source_embed)$
<li role="separator" class="divider"></li>
$endif$
$endif$
$if(source_embed)$
<li><a id="rmd-download-source" href="#">Download Rmd</a></li>
$endif$
</ul>
</div>
$endif$
$endif$
$if(title)$
<h1 class="title toc-ignore">$title$</h1>
$if(subtitle)$
<h3 class="subtitle">$subtitle$</h3>
$endif$
$for(author)$
$if(author.name)$
<h4 class="author">$author.name$</h4>
$if(author.affiliation)$
<address class="author_afil">
$author.affiliation$<br>$endif$
$if(author.email)$
<a class="author_email" href="mailto:#">$author.email$</a>
</address>
$endif$
$else$
<h4 class="author">$author$</h4>
$endif$
$endfor$
$if(date)$
<h4 class="date">$date$</h4>
$endif$
$if(abstract)$
<div class="abstract">
<p class="abstract">Abstract</p>
$abstract$
</div>
$endif$
$endif$
$if(theme)$
</div>
$endif$
$if(toc_float)$
$else$
$if(toc)$
<div id="$idprefix$TOC">
$toc$
</div>
$endif$
$endif$
$body$
$for(include-after)$
$include-after$
$endfor$
$if(theme)$
$if(toc_float)$
</div>
</div>
$endif$
</div>
<script>
// add bootstrap table styles to pandoc tables
function bootstrapStylePandocTables() {
$$('tr.header').parent('thead').parent('table').addClass('table table-condensed');
}
$$(document).ready(function () {
bootstrapStylePandocTables();
});
$if(kable-scroll)$
$$(document).ready(function () {
$$('.knitsql-table').addClass('kable-table');
var container = $$('.kable-table');
container.each(function() {
// move the caption out of the table
var table = $$(this).children('table');
var caption = table.children('caption').detach();
caption.insertBefore($$(this)).css('display', 'inherit');
});
});
$endif$
</script>
<!-- tabsets -->
<script>
$$(document).ready(function () {
window.buildTabsets("$idprefix$TOC");
});
$$(document).ready(function () {
$$('.tabset-dropdown > .nav-tabs > li').click(function () {
$$(this).parent().toggleClass('nav-tabs-open')
});
});
</script>
$endif$
<!-- code folding -->
$if(code_menu)$
<script>
$$(document).ready(function () {
$if(source_embed)$
window.initializeSourceEmbed("$source_embed$");
$endif$
$if(code_folding)$
window.initializeCodeFolding("$code_folding$" === "show");
$endif$
});
</script>
$endif$
$if(toc_float)$
<script>
$$(document).ready(function () {
// move toc-ignore selectors from section div to header
$$('div.section.toc-ignore')
.removeClass('toc-ignore')
.children('h1,h2,h3,h4,h5').addClass('toc-ignore');
// establish options
var options = {
selectors: "$toc_selectors$",
theme: "bootstrap3",
context: '.toc-content',
hashGenerator: function (text) {
return text.replace(/[.\\/?&!#<>]/g, '').replace(/\s/g, '_').toLowerCase();
},
ignoreSelector: ".toc-ignore",
scrollTo: 0
};
$if(toc_collapsed)$
options.showAndHide = true;
$else$
options.showAndHide = false;
$endif$
$if(toc_smooth_scroll)$
options.smoothScroll = true;
$else$
options.smoothScroll = false;
$endif$
// tocify
var toc = $$("#$idprefix$TOC").tocify(options).data("toc-tocify");
});
</script>
$endif$
$if(mathjax-url)$
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "$mathjax-url$";
document.getElementsByTagName("head")[0].appendChild(script);
})();
</script>
$endif$
</body>
</html>

11
inst/rmarkdown/templates/twittercard/skeleton/skeleton.Rmd

@ -0,0 +1,11 @@
---
title: "Doc title which will also get passed to the twitter card"
twitter:
description: "Description for Twitter"
site: "\\@handle"
creator: "\\@handle"
image: "https\\:\\/\\/some.image\\/link\\.png"
output: widgetcard::twitter_document
---
NOTE That the backslash escapes in the `description`, `site`, `creator`, and `image` metadata params are required to prevent pandoc from turning them into unwanted HTML.

4
inst/rmarkdown/templates/twittercard/template.yaml

@ -0,0 +1,4 @@
name: Standard HTML Document with Twitter Tags
description: >
Standard HTML Document with Twitter Tags
create_dir: false

117
man/twitter_document.Rd

@ -0,0 +1,117 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/twitter-doc.R
\name{twitter_document}
\alias{twitter_document}
\title{Standard HTML Document with Twitter Tags}
\usage{
twitter_document(toc = FALSE, toc_depth = 3, toc_float = FALSE,
number_sections = FALSE, section_divs = TRUE, fig_width = 7,
fig_height = 5, fig_retina = 2, fig_caption = TRUE, dev = "png",
df_print = "default", code_folding = c("none", "show", "hide"),
code_download = FALSE, smart = TRUE, self_contained = TRUE,
theme = "default", highlight = "default", mathjax = "default",
extra_dependencies = NULL, css = NULL, includes = NULL,
keep_md = FALSE, lib_dir = NULL, md_extensions = NULL,
pandoc_args = NULL, ...)
}
\arguments{
\item{toc}{\code{TRUE} to include a table of contents in the output}
\item{toc_depth}{Depth of headers to include in table of contents}
\item{toc_float}{\code{TRUE} to float the table of contents to the left of the
main document content. Rather than \code{TRUE} you may also pass a list of
options that control the behavior of the floating table of contents. See the
\emph{Floating Table of Contents} section below for details.}
\item{number_sections}{\code{TRUE} to number section headings}
\item{section_divs}{Wrap sections in <div> tags (or <section> tags in HTML5),
and attach identifiers to the enclosing <div> (or <section>) rather than the
header itself.}
\item{fig_width}{Default width (in inches) for figures}
\item{fig_height}{Default height (in inches) for figures}
\item{fig_retina}{Scaling to perform for retina displays (defaults to 2, which
currently works for all widely used retina displays). Set to \code{NULL} to
prevent retina scaling. Note that this will always be \code{NULL} when
\code{keep_md} is specified (this is because \code{fig_retina} relies on
outputting HTML directly into the markdown document).}
\item{fig_caption}{\code{TRUE} to render figures with captions}
\item{dev}{Graphics device to use for figure output (defaults to png)}
\item{df_print}{Method to be used for printing data frames. Valid values
include "default", "kable", "tibble", and "paged". The "default" method uses
\code{print.data.frame}. The "kable" method uses the
\code{\link[knitr:kable]{knitr::kable}} function. The "tibble" method uses
the \pkg{tibble} package to print a summary of the data frame. The "paged"
method creates a paginated HTML table (note that this method is only valid
for formats that produce HTML). In addition
to the named methods you can also pass an arbitrary function to be used
for printing data frames. You can disable the \code{df_print} behavior entirely
by setting the option \code{rmarkdown.df_print} to \code{FALSE}.}
\item{code_folding}{Enable document readers to toggle the display of R code
chunks. Specify \code{"none"} to display all code chunks (assuming
they were knit with \code{echo = TRUE}). Specify \code{"hide"} to hide all R
code chunks by default (users can show hidden code chunks either
individually or document-wide). Specify \code{"show"} to show all R code
chunks by default.}
\item{code_download}{Embed the Rmd source code within the document and provide
a link that can be used by readers to download the code.}
\item{smart}{Produce typographically correct output, converting straight
quotes to curly quotes, \code{---} to em-dashes, \code{--} to en-dashes, and
\code{...} to ellipses.}
\item{self_contained}{Produce a standalone HTML file with no external
dependencies, using data: URIs to incorporate the contents of linked
scripts, stylesheets, images, and videos. Note that even for self contained
documents MathJax is still loaded externally (this is necessary because of
its size).}
\item{theme}{Visual theme ("default", "cerulean", "journal", "flatly",
"darkly", "readable", "spacelab", "united", "cosmo", "lumen", "paper",
"sandstone", "simplex", or "yeti"). Pass \code{NULL} for no theme (in this
case you can use the \code{css} parameter to add your own styles).}
\item{highlight}{Syntax highlighting style. Supported styles include
"default", "tango", "pygments", "kate", "monochrome", "espresso", "zenburn",
"haddock", and "textmate". Pass \code{NULL} to prevent syntax highlighting.}
\item{mathjax}{Include mathjax. The "default" option uses an https URL from a
MathJax CDN. The "local" option uses a local version of MathJax (which is
copied into the output directory). You can pass an alternate URL or pass
\code{NULL} to exclude MathJax entirely.}
\item{extra_dependencies}{Additional function arguments to pass to the
base R Markdown HTML output formatter \code{\link{html_document_base}}}
\item{css}{One or more css files to include}
\item{includes}{Named list of additional content to include within the
document (typically created using the \code{\link{includes}} function).}
\item{keep_md}{Keep the markdown file generated by knitting.}
\item{lib_dir}{Directory to copy dependent HTML libraries (e.g. jquery,
bootstrap, etc.) into. By default this will be the name of the document with
\code{_files} appended to it.}
\item{md_extensions}{Markdown extensions to be added or removed from the
default definition or R Markdown. See the \code{\link{rmarkdown_format}} for
additional details.}
\item{pandoc_args}{Additional command line options to pass to pandoc}
\item{...}{Additional function arguments to pass to the
base R Markdown HTML output formatter \code{\link{html_document_base}}}
}
\description{
Standard HTML Document with Twitter Tags
}
Loading…
Cancel
Save