diff --git a/R/tags.R b/R/tags.R index 64814472..eff166cb 100644 --- a/R/tags.R +++ b/R/tags.R @@ -395,7 +395,13 @@ tagWrite <- function(tag, textWriter, indent=0, eol = "\n") { textWriter(paste8(indentText, "<", tag$name, sep="")) # Convert all attribs to chars explicitly; prevents us from messing up factors - attribs <- lapply(tag$attribs, as.character) + attribs <- lapply(tag$attribs, function(x){ + if(inherits(x, c("AsIs","noquote"))){ + x + } else { + as.character(x) + } + }) # concatenate attributes # split() is very slow, so avoid it if possible if (anyDuplicated(names(attribs))) @@ -404,12 +410,15 @@ tagWrite <- function(tag, textWriter, indent=0, eol = "\n") { # write attributes for (attrib in names(attribs)) { attribValue <- attribs[[attrib]] - if (!is.na(attribValue)) { + if (!is.na(attribValue) && !inherits(attribValue,c("AsIs","noquote"))) { if (is.logical(attribValue)) attribValue <- tolower(attribValue) text <- htmlEscape(attribValue, attribute=TRUE) textWriter(paste8(" ", attrib,"=\"", text, "\"", sep="")) } + else if(inherits(attribValue,c("AsIs","noquote"))){ + textWriter(paste8(" ", attrib, "=", attribValue, sep="") ) + } else { textWriter(paste8(" ", attrib, sep="")) }