1 sanitize <- function(str, type) {
4 result <- gsub("\\\\", "SANITIZE.BACKSLASH", result)
5 result <- gsub("$", "\\$", result, fixed = TRUE)
6 result <- gsub(">", "$>$", result, fixed = TRUE)
7 result <- gsub("<", "$<$", result, fixed = TRUE)
8 result <- gsub("|", "$|$", result, fixed = TRUE)
9 result <- gsub("{", "\\{", result, fixed = TRUE)
10 result <- gsub("}", "\\}", result, fixed = TRUE)
11 result <- gsub("%", "\\%", result, fixed = TRUE)
12 result <- gsub("&", "\\&", result, fixed = TRUE)
13 result <- gsub("_", "\\_", result, fixed = TRUE)
14 result <- gsub("#", "\\#", result, fixed = TRUE)
15 result <- gsub("^", "\\verb|^|", result, fixed = TRUE)
16 result <- gsub("~", "\\~{}", result, fixed = TRUE)
17 result <- gsub("SANITIZE.BACKSLASH", "$\\backslash$", result, fixed = TRUE)
21 result <- gsub("&", "&", result, fixed = TRUE)
22 result <- gsub(">", ">", result, fixed = TRUE)
23 result <- gsub("<", "<", result, fixed = TRUE)
29 sanitize.numbers <- function(str, type, math.style.negative){
32 if ( math.style.negative ) {
33 for(i in 1:length(str)) {
34 result[i] <- gsub("-", "$-$", result[i], fixed = TRUE)
44 sanitize.final <- function(str, type){
48 str$text <- gsub(" *", " ", str$text, fixed = TRUE)
49 str$text <- gsub(' align="left"', "", str$text,