Skip to contents

This function extracts the content from a given text string that is enclosed between the '```' markers. It can be used to extract any kind of code or text content.

Usage

clean_output(text)

Arguments

text

A character string containing the code or text content with '```' markers.

Value

A character string containing the extracted code or text content.

Author

Ulrich Matter umatter@protonmail.com

Examples

code_text <- "```
example_code <- function(x) {
  return(x * 2)
}
```"
clean_output(code_text)
#> [1] "\nexample_code <- function(x) {\n  return(x * 2)\n}\n"