Title: | Embed Tweets in R Markdown |
---|---|
Description: | Easily embed Tweets anywhere R Markdown turns plain text into HTML. |
Authors: | Garrick Aden-Buie [aut, cre] |
Maintainer: | Garrick Aden-Buie <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.10 |
Built: | 2024-11-11 04:45:09 UTC |
Source: | https://github.com/gadenbuie/tweetrmd |
Similar to knitr::include_graphics()
, but for tweets. In HTML documents,
the tweet is embedded using tweet_embed()
and for all other documents types
a screen shot of the tweet is rendered and used tweet_screenshot()
. If you
would rather that just the text of the tweet be included in non-HTML outputs,
use tweet_embed()
.
include_tweet(tweet_url, plain = FALSE, ...) tweet_markdown(tweet_url, ...)
include_tweet(tweet_url, plain = FALSE, ...) tweet_markdown(tweet_url, ...)
tweet_url |
The URL for the tweet, or use |
plain |
Embeds the tweet without including Twitter's JavaScript code.
This means the tweets will be displayed as minimally styled HTML in
Note that for HTML outputs, you can't selectively choose whether or not a tweet is rendered in plain HTML if you include multiple tweet. Including one rich embedded tweet will trigger rich embedding of all tweets loaded on the page. |
... |
Arguments passed on to
|
An htmltools::tagList()
to include a tweet in an HTML document, or
a screen shot of the tweet for use in non-HTML outputs.
tweet_markdown
: Return a tweet as plain markdown.
Other Tweet-embedding functions:
tweet_embed()
,
tweet_screenshot()
include_tweet("https://twitter.com/dsquintana/status/1275705042385940480")
include_tweet("https://twitter.com/dsquintana/status/1275705042385940480")
Uses Twitter's oembed API to embed a tweet in R Markdown HTML outputs.
tweet_embed( tweet_url, maxwidth = 550, plain = FALSE, hide_media = FALSE, hide_thread = FALSE, omit_script = TRUE, align = c("none", "left", "right", "center"), related = NULL, lang = "en", theme = c("light", "dark"), link_color = NULL, widget_type = NULL, dnt = TRUE ) tweet_url(screen_name = NULL, status_id) screen_name %tweet% status_id
tweet_embed( tweet_url, maxwidth = 550, plain = FALSE, hide_media = FALSE, hide_thread = FALSE, omit_script = TRUE, align = c("none", "left", "right", "center"), related = NULL, lang = "en", theme = c("light", "dark"), link_color = NULL, widget_type = NULL, dnt = TRUE ) tweet_url(screen_name = NULL, status_id) screen_name %tweet% status_id
tweet_url |
The URL for the tweet, or use |
maxwidth |
The maximum width of a rendered Tweet in whole pixels. A
supplied value under or over the allowed range will be returned as the
minimum or maximum supported width respectively; the reset width value will
be reflected in the returned |
plain |
Embeds the tweet without including Twitter's JavaScript code.
This means the tweets will be displayed as minimally styled HTML in
Note that for HTML outputs, you can't selectively choose whether or not a tweet is rendered in plain HTML if you include multiple tweet. Including one rich embedded tweet will trigger rich embedding of all tweets loaded on the page. |
hide_media |
When set to |
hide_thread |
When set to |
omit_script |
When set to |
align |
Specifies whether the embedded Tweet should be floated left, right, or center in the page relative to the parent element. |
related |
A comma-separated list of Twitter usernames related to your content. This value will be forwarded to Tweet action intents if a viewer chooses to reply, like, or retweet the embedded Tweet. |
lang |
Request returned HTML and a rendered Tweet in the specified Twitter language supported by embedded Tweets. |
theme |
When set to |
link_color |
Adjust the color of Tweet text links with a hexadecimal color value. |
widget_type |
Set to |
dnt |
When set to |
screen_name |
The user's screen name |
status_id |
The tweet's status id |
The placeholder HTML for the tweet
tweet_url
: Create a URL for a tweet from a screen name and status id.
%tweet%
: A shortcut for the impatient.
https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-oembed
Other Tweet-embedding functions:
include_tweet()
,
tweet_screenshot()
## Not run: # these are equivalent tweet_embed("https://twitter.com/alexpghayes/status/1211748406730706944") tweet_embed(tweet_url("alexpghayes", "1211748406730706944")) tweet_embed("1211748406730706944") # Adding many tweets at once to a document takes a little bit more work thread <- c( "https://twitter.com/grrrck/status/1333804309272621060", "https://twitter.com/grrrck/status/1333804487148855300", "https://twitter.com/grrrck/status/1333805092152123394" ) htmltools::tagList( lapply(thread, tweet_embed, plain = TRUE) ) ## End(Not run)
## Not run: # these are equivalent tweet_embed("https://twitter.com/alexpghayes/status/1211748406730706944") tweet_embed(tweet_url("alexpghayes", "1211748406730706944")) tweet_embed("1211748406730706944") # Adding many tweets at once to a document takes a little bit more work thread <- c( "https://twitter.com/grrrck/status/1333804309272621060", "https://twitter.com/grrrck/status/1333804487148855300", "https://twitter.com/grrrck/status/1333805092152123394" ) htmltools::tagList( lapply(thread, tweet_embed, plain = TRUE) ) ## End(Not run)
Takes a screenshot of the tweet that is automatically embedded in R Markdown documents or that can be saved for use later.
tweet_screenshot( tweet_url, maxwidth = 550, scale = 2, file = NULL, link_color = NULL, ... )
tweet_screenshot( tweet_url, maxwidth = 550, scale = 2, file = NULL, link_color = NULL, ... )
tweet_url |
The URL for the tweet, or use |
maxwidth |
The maximum width of a rendered Tweet in whole pixels. A
supplied value under or over the allowed range will be returned as the
minimum or maximum supported width respectively; the reset width value will
be reflected in the returned |
scale |
Scale the tweet for a better quality screenshot. Default is 2. |
file |
A character string of output files. Can end with |
link_color |
Adjust the color of Tweet text links with a hexadecimal color value. |
... |
Arguments passed on to
|
Other Tweet-embedding functions:
include_tweet()
,
tweet_embed()
## Not run: tmpimg <- tempfile(fileext = "png") tweet_screenshot( tweet_url = "https://twitter.com/alexpghayes/status/1211748406730706944", file = tmpimg ) ## End(Not run)
## Not run: tmpimg <- tempfile(fileext = "png") tweet_screenshot( tweet_url = "https://twitter.com/alexpghayes/status/1211748406730706944", file = tmpimg ) ## End(Not run)