Converts a language object (like the body of a function) to a vector of character strings that roughly translate to one line per entry

language_to_character(lang)

Arguments

lang

language; language object to be converted

Value

vector; vector of character strings with roughly one line per entry

Examples

language_to_character(functionBody(language_to_character))
#> [1] "if (is.character(lang)) {" #> [2] " return(lang)}" #> [3] "raw_char <- as.character(lang)" #> [4] "raw_char <- raw_char[2:length(raw_char)]" #> [5] "if (raw_char[[length(raw_char)]] == \"}\") {" #> [6] " raw_char <- raw_char[1:(length(raw_char) - 1)]}" #> [7] "g1 <- gsub(x = raw_char, pattern = \"\\n\", replacement = \"\")" #> [8] "g2 <- gsub(x = g1, pattern = \"\\\\s{3}\", replacement = \"\\\\1\\n\")" #> [9] "unlist(strsplit(g2, \"\\n\"))"