move_asterisks: INTERNAL - Move asterisks around so that you can put...

View source: R/move_asterisks.R

move_asterisksR Documentation

INTERNAL - Move asterisks around so that you can put asterisks around that string and things will be italicized appropriately

Description

move_asterisks finds all locations of an asterisk plus a space or a space plus an asterisk and swaps the positions of the spaces and the asterisks. It also makes sure that your string doesn't end in two asterisks by removing the terminal asterisk.

How to use this: Say you've got a string that is a figure caption with two italicized references included inside the string. If you try to put the whole caption in italics in a .Rmd file with *`r MyCaption`*, the italics will be messed up and you will likely have an extra asterisk at the end of the final output in the knitted document. This fixes that.

Usage

move_asterisks(string, num_asterisks_to_match = NA)

Arguments

string

a string of text, e.g., a figure or table caption for use in an Rmarkdown document that will be italicized

num_asterisks_to_match

number of asterisks to match and move. If left as NA, this will move sets of 3, 2, and then 1 asterisks. If set to 3, 2, or 1, though, it will only look for that number to match and move.

Value

a string


shirewoman2/Consultancy documentation built on Feb. 18, 2025, 10 p.m.