19 |
19 |
20 if new_format != 'html': |
20 if new_format != 'html': |
21 newVersionContent = pandoc_convert(new_content, new_format, 'html') |
21 newVersionContent = pandoc_convert(new_content, new_format, 'html') |
22 else: |
22 else: |
23 newVersionContent = new_content |
23 newVersionContent = new_content |
24 |
24 |
|
25 #$$$$$ |
|
26 #import pdb;pdb.set_trace() |
25 _, previous_char_list, span_starts_previous = spannify(previousVersionContent) |
27 _, previous_char_list, span_starts_previous = spannify(previousVersionContent) |
26 _, new_char_list, span_starts_new = spannify(newVersionContent) |
28 _, new_char_list, span_starts_new = spannify(newVersionContent) |
27 |
29 |
28 sm = SequenceMatcher(None, previous_char_list, new_char_list) |
30 sm = SequenceMatcher(None, previous_char_list, new_char_list) |
29 |
31 |
66 elif comment.initial_end_offset > i1: |
68 elif comment.initial_end_offset > i1: |
67 comment.valid = False |
69 comment.valid = False |
68 |
70 |
69 # id, initial_start, initial_end, computed_start, computed_end, valid = self.computationResults[i] |
71 # id, initial_start, initial_end, computed_start, computed_end, valid = self.computationResults[i] |
70 |
72 |
71 for c in commentList: |
73 for cc in commentList: |
72 if c.valid: |
74 if cc.valid: |
73 for id in xrange(len(span_starts_new.keys())): |
75 for id in xrange(len(span_starts_new.keys())): |
74 start = span_starts_new.get(id) |
76 start = span_starts_new.get(id) |
75 end = span_starts_new.get(id+1, sys.maxint) |
77 end = span_starts_new.get(id+1, sys.maxint) |
76 |
78 |
77 # adjust start |
79 # adjust start |
78 if c.computed_start_offset >= start and c.computed_start_offset < end: |
80 if cc.computed_start_offset >= start and cc.computed_start_offset < end: |
79 c.start_wrapper = id |
81 cc.start_wrapper = id |
80 c.start_offset = c.computed_start_offset - start |
82 cc.start_offset = cc.computed_start_offset - start |
81 |
83 |
82 # adjust end |
84 # adjust end |
83 if c.computed_end_offset >= start and c.computed_end_offset < end: |
85 if cc.computed_end_offset >= start and cc.computed_end_offset < end: |
84 c.end_wrapper = id |
86 cc.end_wrapper = id |
85 c.end_offset = c.computed_end_offset - start |
87 cc.end_offset = cc.computed_end_offset - start |
86 |
88 |
87 # returns to_modify, to_remove |
89 # returns to_modify, to_remove |
88 return [c for c in commentList if c.valid], \ |
90 return [c for c in commentList if c.valid], \ |
89 [c for c in commentList if not c.valid] |
91 [c for c in commentList if not c.valid] |
90 |
92 |