[jsword-svn] jsword/java/jsword/org/crosswire/jsword/book/filter/plaintext s

jswordcvs at crosswire.org jswordcvs at crosswire.org
Fri Mar 11 06:07:35 MST 2005


Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/filter/plaintext
In directory www.crosswire.org:/tmp/cvs-serv6149/java/jsword/org/crosswire/jsword/book/filter/plaintext

Modified Files:
	PlainTextFilter.java 
Log Message:
Improved the PlainTextFilter. It was not preserving whitespace, which is ok for Jubilee2000, but not for Naves.

Index: PlainTextFilter.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/filter/plaintext/PlainTextFilter.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** PlainTextFilter.java	5 Mar 2005 22:08:06 -0000	1.5
--- PlainTextFilter.java	11 Mar 2005 13:07:33 -0000	1.6
***************
*** 3,6 ****
--- 3,7 ----
  import java.util.List;
  
+ import org.crosswire.common.util.StringUtil;
  import org.crosswire.jsword.book.OSISUtil;
  import org.crosswire.jsword.book.filter.Filter;
***************
*** 10,13 ****
--- 11,17 ----
  /**
   * Filter to convert plain text to OSIS format.
+  * Plain text is nothing more than lines without markup.
+  * Unfortunately, it often uses whitespace for markup.
+  * We will use OSIS lb to mark lines.
   * 
   * <p><table border='1' cellPadding='3' cellSpacing='0'>
***************
*** 39,44 ****
      public List toOSIS(Key key, String plain)
      {
!         Element ele = OSISUtil.factory().createDiv();
!         ele.addContent(plain);
          return ele.removeContent();
      }
--- 43,63 ----
      public List toOSIS(Key key, String plain)
      {
!         OSISUtil.ObjectFactory factory = OSISUtil.factory();
!         Element ele = factory.createDiv();
! 
!         String[] lines = StringUtil.splitAll(plain, '\n');
!         int lastIndex = lines.length - 1;
!         for (int i = 0; i < lastIndex; i++)
!         {
!             // TODO(DMS): Preserve whitespace, in a smart manner.
!             ele.addContent(lines[i]);
!             ele.addContent(factory.createLB());
!         }
!         // Don't add a line break after the last line.
!         if (lastIndex >= 0)
!         {
!             ele.addContent(lines[lastIndex]);
!         }
! 
          return ele.removeContent();
      }



More information about the jsword-svn mailing list