add_line_breaks: Add line breaks to one or more strings

View source: R/add_line_breaks.R

add_line_breaksR Documentation

Add line breaks to one or more strings

Description

This function takes a vector of strings and adds line breaks every n characters. Primarily built to be called internally by format_citation(), this function has been made available as it can be useful in other contexts.

Usage

add_line_breaks(x, n = 50, html = FALSE)

Arguments

x

Either a string or a vector; if the vector is not of class character if will be coerced to one using as.character().

n

Numeric: The desired number of characters that should separate consecutive line breaks.

html

Logical: Should the line breaks be specified in html?

Details

Line breaks are only added between words, so the value of n is actually a threshold value rather than being matched exactly.

Value

Returns the input vector unaltered except for the addition of line breaks.

Examples

add_line_breaks(c("On the Origin of Species"), n = 10)

synthesisr documentation built on March 26, 2026, 5:09 p.m.