10 import html5lib |
10 import html5lib |
11 from html5lib import treebuilders |
11 from html5lib import treebuilders |
12 |
12 |
13 def compute_new_comment_positions(old_content, old_format, new_content, new_format, commentList): |
13 def compute_new_comment_positions(old_content, old_format, new_content, new_format, commentList): |
14 |
14 |
15 if old_format!='html': |
15 # cf. TextVersion.get_content |
16 previousVersionContent = pandoc_convert(old_content, old_format, 'html') |
16 previousVersionContent = pandoc_convert(old_content, old_format, 'html') |
17 else: |
17 newVersionContent = pandoc_convert(new_content, new_format, 'html') |
18 previousVersionContent = old_content |
18 |
19 |
|
20 if new_format != 'html': |
|
21 newVersionContent = pandoc_convert(new_content, new_format, 'html') |
|
22 else: |
|
23 newVersionContent = new_content |
|
24 _, previous_char_list, span_starts_previous = spannify(previousVersionContent) |
19 _, previous_char_list, span_starts_previous = spannify(previousVersionContent) |
25 _, new_char_list, span_starts_new = spannify(newVersionContent) |
20 _, new_char_list, span_starts_new = spannify(newVersionContent) |
26 |
21 |
27 sm = SequenceMatcher(None, previous_char_list, new_char_list) |
22 sm = SequenceMatcher(None, previous_char_list, new_char_list) |
28 |
23 |