Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions R/tags.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand All @@ -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=""))
}
Expand Down