changeset 23:9457add294b8

Record paragraph numbers, not line numbers.
author Bryan O'Sullivan <bos@serpentine.com>
date Sun, 09 Jul 2006 21:47:02 -0700
parents 5ad16196cef4
children a752b0fd3c10
files en/fblinks
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/en/fblinks	Sun Jul 09 21:29:19 2006 -0700
+++ b/en/fblinks	Sun Jul 09 21:47:02 2006 -0700
@@ -18,8 +18,8 @@
     if err.errno != errno.EEXIST:
         raise
 
-def feedback(name, text, line):
-    return r'\marginpar{\scriptsize \href{http://demesne:8000/book/feedback/submit/%s/%s/%d/}{Feedback}}' % (hg_id, name, line)
+def feedback(name, text, ctx_id):
+    return r'\marginpar{\scriptsize \href{http://demesne:8000/book/feedback/submit/%s/%s/%d/}{Feedback}}' % (hg_id, name, ctx_id)
 
 ctxs = {}
 try:
@@ -41,16 +41,18 @@
     ofp = open(dest_name, 'w')
     new_par = True
     line_num = 0
+    par_num = 0
     for line in ifp:
         line_num += 1
         if new_par:
             m = line_re.match(line)
             if m:
+                par_num += 1
                 ls = line.strip()
-                if ctxs.get((name, line_num)) != ls:
-                    ctxs[(name, line_num)] = ls
+                if ctxs.get((name, par_num)) != ls:
+                    ctxs[(name, par_num)] = ls
                     changes += 1
-                line = m.group(1) + feedback(name, line, line_num) + m.group(2)
+                line = m.group(1) + feedback(name, line, par_num) + m.group(2)
                 new_par = False
         elif not line.strip():
             new_par = True