]> granicus.if.org Git - python/commitdiff
convert(): Make sure no line has trailing whitespace. (docfixer.py
authorFred Drake <fdrake@acm.org>
Thu, 7 Jan 1999 18:47:07 +0000 (18:47 +0000)
committerFred Drake <fdrake@acm.org>
Thu, 7 Jan 1999 18:47:07 +0000 (18:47 +0000)
checks for \n\n as a paragraph separator, LaTeX allows white
space between the newlines.)

Doc/tools/sgmlconv/latex2esis.py

index f3c39f58b2ca0f65a4f92e30f8e9298fccd508e0..4a86747600fdbbb44d669c046e83e3cca619dad5 100755 (executable)
@@ -53,8 +53,6 @@ def subconvert(line, ofp, table, discards, autoclosing, endchar=None):
                 ofp.write("- %s \n" % encode(text))
                 ofp.write(")COMMENT\n")
                 ofp.write("-\\n\n")
-##             else:
-##                 ofp.write("-\\n\n")
             line = line[m.end():]
             continue
         m = _begin_env_rx.match(line)
@@ -250,8 +248,12 @@ def subconvert(line, ofp, table, discards, autoclosing, endchar=None):
 
 
 def convert(ifp, ofp, table={}, discards=(), autoclosing=()):
+    lines = string.split(ifp.read(), "\n")
+    for i in range(len(lines)):
+        lines[i] = string.rstrip(lines[i])
+    data = string.join(lines, "\n")
     try:
-        subconvert(ifp.read(), ofp, table, discards, autoclosing)
+        subconvert(data, ofp, table, discards, autoclosing)
     except IOError, (err, msg):
         if err != errno.EPIPE:
             raise