|
[HepData-svn] r1514 - trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/componentsblackhole at projects.hepforge.org blackhole at projects.hepforge.orgThu Feb 23 10:29:17 GMT 2012
Author: whalley Date: Thu Feb 23 10:29:17 2012 New Revision: 1514 Log: mods to allow more control of formatting of comments in paper and datasets ... using the # symbol to force a new line. Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/DatasetAsHtml.java trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/DisplayPaperComments.java Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/DatasetAsHtml.java ============================================================================== --- trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/DatasetAsHtml.java Wed Feb 22 09:42:01 2012 (r1513) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/DatasetAsHtml.java Thu Feb 23 10:29:17 2012 (r1514) @@ -35,8 +35,21 @@ writer.element("p"); writer.attributes("class", "datasetcomments"); for (String comment : _dataset.getComments()) { - writer.element("br"); writer.end(); - writer.write(comment); + int ls=comment.length(); + while (ls>0){ + int iend = ls; + int ihash = comment.indexOf("#"); + if(ihash>0) { iend = ihash; } + writer.element("br"); writer.end(); + writer.write(comment.substring(0,iend)); + if(iend<ls){ + comment=comment.substring(ihash+1); + ls=comment.length(); + } else { + ls=0; + } + } + } // now try to deal with additional dataset errors... Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/DisplayPaperComments.java ============================================================================== --- trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/DisplayPaperComments.java Wed Feb 22 09:42:01 2012 (r1513) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/DisplayPaperComments.java Thu Feb 23 10:29:17 2012 (r1514) @@ -47,18 +47,46 @@ else {comment = "";} } } - int istart = 0; - int linelength = 80; +// String bs = b.toString(); +// int istart = 0; +// int linelength = 80; +// while(istart<b.length()){ +// int imax=istart+linelength; +// if(imax > b.length()){imax=b.length();} +// // force a new line with a # symbol +// int iendhash = bs.substring(istart,imax).indexOf("#"); +// int iendspace = bs.substring(istart,imax).lastIndexOf(" "); +// int iend = iendspace; +// if(iendhash>=0 && iendhash<iendspace) { iend = iendhash;} +// writer.element("br");writer.end(); +// writer.write(bs.substring(istart,istart+iend)); +// istart=istart+iend+1; +// } + + // new way String bs = b.toString(); - while(istart<b.length()){ - int imax=istart+linelength; - if(imax > b.length()){imax=b.length();} - int iend=bs.substring(0,imax).lastIndexOf(" "); - writer.element("br");writer.end(); - writer.write(bs.substring(istart,iend)); - istart=iend+1; + int ls=bs.length(); + System.out.println(bs + " " + ls); + while (ls>0){ + int iend = ls; + int ihash = bs.indexOf("#"); + System.out.println("ihash "+ihash+" iend " + ls); + + if(ihash>=0) { iend = ihash; } + writer.element("br"); writer.end(); + writer.write(bs.substring(0,iend)); + if(iend<ls){ + bs=bs.substring(ihash+1); + ls=bs.length(); + } else { + ls=0; + } } + writer.end(); + + + } }
More information about the HepData-svn mailing list |