[rkward] packages/XiMpLe: tried to improve comment sections
m.eik michalke
meik.michalke at uni-duesseldorf.de
Sun Nov 15 22:20:25 UTC 2015
Git commit 36628d82479a2f630ff5238316d72f2a08a6fad3 by m.eik michalke.
Committed on 15/11/2015 at 21:12.
Pushed by meikm into branch 'master'.
tried to improve comment sections
- still work to do here
M +2 -0 packages/XiMpLe/ChangeLog
M +7 -6 packages/XiMpLe/R/XiMpLe-internal.R
http://commits.kde.org/rkward/36628d82479a2f630ff5238316d72f2a08a6fad3
diff --git a/packages/XiMpLe/ChangeLog b/packages/XiMpLe/ChangeLog
index e846f75..9ce3f1d 100644
--- a/packages/XiMpLe/ChangeLog
+++ b/packages/XiMpLe/ChangeLog
@@ -9,6 +9,8 @@ fixed:
- XMLScanDeep() was said to examine node names, children and values as well
as attributes, but in fact it was hard-wired on attributes only. removed
children from the list and added support for names and values
+ - corrected internal function setMinIndent() for better indentation for comments
+ - internal function indent() can now handle negative levels
changes in version 0.03-22 (2014-12-02)
fixed:
diff --git a/packages/XiMpLe/R/XiMpLe-internal.R b/packages/XiMpLe/R/XiMpLe-internal.R
index 47f591b..6f576de 100644
--- a/packages/XiMpLe/R/XiMpLe-internal.R
+++ b/packages/XiMpLe/R/XiMpLe-internal.R
@@ -144,25 +144,26 @@ XML.single.tags <- function(tree, drop=NULL){
# and adjusts it globally to the given level
setMinIndent <- function(tag, level=1, indent.by="\t", shine=0){
if(shine > 0){
- tag <- gsub("\n([^\t])", "\n\t\\1", tag, perl=TRUE)
+ tag <- gsub("\n([^\t])", paste0("\n",indent.by,"\\1"), tag, perl=TRUE)
} else {}
currentMinIndent <- min(nchar(unlist(strsplit(tag, "[^\t]+"), use.names=FALSE)))
indentDiff <- currentMinIndent - level
+ tagParts <- unlist(strsplit(tag, "\n"))
# if currentMinIndent is greater than level, reduce indentation
if(indentDiff > 0){
- tag <- gsub(paste0("(^|\n)(\t){", indentDiff, "}"), "\\1", tag, perl=TRUE)
+ tagParts <- gsub(paste0("(^|\n)(\t){", indentDiff, "}"), "\\1", tagParts, perl=TRUE)
} else if(indentDiff < 0){
- tag <- gsub("(^|\n)(\t)", paste0("\\1", indent(level + 1, by=indent.by)), tag, perl=TRUE)
+ tagParts <- paste0(indent(level=level, by=indent.by), tagParts)
} else {}
-
- return(tag)
+
+ return(paste0(tagParts, collapse="\n"))
} ## end function setMinIndent()
## function indent()
# will create tabs to format the output
indent <- function(level, by="\t"){
- paste(rep(by, level-1), collapse="")
+ paste(rep(by, max(0, level-1)), collapse="")
} ## end function indent()
More information about the rkward-tracker
mailing list