[rkward-cvs] SF.net SVN: rkward:[4213] trunk/rkward/packages/XiMpLe/R
m-eik at users.sourceforge.net
m-eik at users.sourceforge.net
Thu Apr 26 12:58:18 UTC 2012
Revision: 4213
http://rkward.svn.sourceforge.net/rkward/?rev=4213&view=rev
Author: m-eik
Date: 2012-04-26 12:58:17 +0000 (Thu, 26 Apr 2012)
Log Message:
-----------
XiMpLe: some improvement on the indentation, now there's only one problem left unsolved: the overall indentation level for text is incorrect (+1)
Modified Paths:
--------------
trunk/rkward/packages/XiMpLe/R/XiMpLe-internal.R
trunk/rkward/packages/XiMpLe/R/pasteXMLTag.R
Modified: trunk/rkward/packages/XiMpLe/R/XiMpLe-internal.R
===================================================================
--- trunk/rkward/packages/XiMpLe/R/XiMpLe-internal.R 2012-04-26 09:20:58 UTC (rev 4212)
+++ trunk/rkward/packages/XiMpLe/R/XiMpLe-internal.R 2012-04-26 12:58:17 UTC (rev 4213)
@@ -110,16 +110,16 @@
# takes a string, determines the minimum number of grouped \t strings,
# and adjusts it globally to the given level
setMinIndent <- function(tag, level=1, indent.by="\t", shine=0){
- currentMinIndent <- min(nchar(unlist(strsplit(tag, "[^\t]+"))))
if(shine > 0){
- tag <- gsub("\n([^\t]+)", "\n\t\\1", tag, perl=TRUE)
+ tag <- gsub("\n([^\t])", "\n\t\\1", tag, perl=TRUE)
} else {}
+ currentMinIndent <- min(nchar(unlist(strsplit(tag, "[^\t]+"))))
indentDiff <- currentMinIndent - level
# if currentMinIndent is greater than level, reduce indentation
if(indentDiff > 0){
- tag <- gsub(paste("(^|[^\t]+)(\t){", indentDiff, "}", sep=""), "\\1", tag, perl=TRUE)
+ tag <- gsub(paste("(^|\n)(\t){", indentDiff, "}", sep=""), "\\1", tag, perl=TRUE)
} else if(indentDiff < 0){
- tag <- gsub("(^|[^\t]+)(\t)", paste("\\1", indent(level + 1, by=indent.by), sep=""), tag, perl=TRUE)
+ tag <- gsub("(^|\n)(\t)", paste("\\1", indent(level + 1, by=indent.by), sep=""), tag, perl=TRUE)
} else {}
return(tag)
Modified: trunk/rkward/packages/XiMpLe/R/pasteXMLTag.R
===================================================================
--- trunk/rkward/packages/XiMpLe/R/pasteXMLTag.R 2012-04-26 09:20:58 UTC (rev 4212)
+++ trunk/rkward/packages/XiMpLe/R/pasteXMLTag.R 2012-04-26 12:58:17 UTC (rev 4213)
@@ -43,15 +43,19 @@
# three special cases: value pseudotags, comments and CDATA
if(isTRUE(nchar(tag) == 0) | length(tag) == 0){
+ if(isTRUE(tidy)){
+ child <- trim(child)
+ child <- gsub("\n", new.cmmt, setMinIndent(child, level=level, indent.by=indent.by, shine=shine))
+ }
full.tag <- paste(child, " ", sep="")
} else {
switch(tag,
"!--"={
# clean up value if needed
if(!is.null(child)){
- child <- trim(child)
if(isTRUE(tidy)){
- child <- gsub("\n", new.cmmt, setMinIndent(child, level=level + 1, indent.by=indent.by, shine=shine))
+ child <- trim(child)
+ child <- gsub("\n", new.cmmt, setMinIndent(child, level=level, indent.by=indent.by, shine=shine))
}
} else {}
full.tag <- paste(new.indent, "<!-- ", new.attr, new.cmmt.indent,
@@ -62,7 +66,7 @@
if(!is.null(child)){
child <- trim(child)
if(isTRUE(tidy)){
- child <- gsub("\n", new.cmmt, setMinIndent(child, level=level + 1, indent.by=indent.by))
+ child <- gsub("\n", new.cmmt, setMinIndent(child, level=level, indent.by=indent.by))
}
} else {}
full.tag <- paste(new.indent, "<![CDATA[ ", new.cmmt, comment.indent,
@@ -73,7 +77,7 @@
if(!is.null(child)){
child <- trim(child)
if(isTRUE(tidy)){
- child <- gsub("\n", new.cmmt, setMinIndent(child, level=level + 1, indent.by=indent.by))
+ child <- gsub("\n", new.cmmt, setMinIndent(child, level=level, indent.by=indent.by))
}
} else {}
#
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list