Skip to contents

Given a toot_df, append a thread counter to the end of every toot. By default, the thread counter has the format "\U1F9F5 n/N" (Unicode character 1F9F5 is the "thread emoji"; see cat("\U1F9F5")).

Usage

append_thread_counter(
  x,
  sep = getOption("quartodon_counter_sep", "\n\n"),
  prefix = getOption("quartodon_counter_prefix", "🧵"),
  delim = getOption("quartodon_counter_delim", "/"),
  suffix = getOption("quartodon_counter_suffix", "")
)

Arguments

x

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

sep

The character(s) to insert between the original toot and the thread counter.

prefix

The prefix to insert before the thread counter.

delim

The character(s) to insert in between the number of the current toot and the total number of toots.

suffix

The character(s) to insert after the thread counter.

Value

The toot_df passed as x, with the toots column replaced (with the thread counters appended).

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
);