Skip to contents

The function creates an HTML file with a preview of the toots that would be posted if x would be passed to post_thread_from_df() instead.

Usage

preview_toot_df(
  x,
  select = NULL,
  embed = FALSE,
  filename = tempfile(pattern = "quartodon_preview", fileext = ".html"),
  encoding = getOption("quartodon_encoding", "UTF-8")
)

Arguments

x

A toot_df as produced by a call to prep_and_check_toot_df() or append_thread_counter(); or the object produced by a call to split_to_toots(), or the toot_df contained in such an object (in $df).

select

Optionally, the number(s) of the toot(s) to select to preview.

embed

Whether to only return the HTML code to be included in a <body> tag of an existing HTML file. If embed=TRUE, nothing is shown in the viewer and no files are written.

filename

The file to write the HTML with the preview to.

encoding

The encoding to use when writing the file.

Value

Invisibly, the filename in which the HTML is stored.

Examples

### Get example post directory
examplePostDir <-
  system.file("example-post",
              package = "quartodon");

### Get an example text (see the intro vignette)
exampleText <-
  readLines(
    file.path(examplePostDir, "quartodon.Rmd"),
    encoding = "UTF-8"
  );

### Extract the toots
extractedToots <- quartodon::split_to_toots(
  exampleText
);

### Append the thread counters
toot_df <- quartodon::append_thread_counter(
  extractedToots
);

### Prepare and check the toots (for length, existing
### images, etc)
toot_df <- quartodon::prep_and_check_toot_df(
  toot_df,
  postsPath = examplePostDir
);

### Preview the thread in the viewer
previewFile <- quartodon::preview_toot_df(
  toot_df
);