equal
deleted
inserted
replaced
28 sm = SequenceMatcher(None, previous_char_list, new_char_list) |
28 sm = SequenceMatcher(None, previous_char_list, new_char_list) |
29 |
29 |
30 opcodes = sm.get_opcodes() |
30 opcodes = sm.get_opcodes() |
31 to_remove_comments_ids = set() |
31 to_remove_comments_ids = set() |
32 |
32 |
33 # limit to real comments (not replies) |
33 # limit to real comments (not replies) and those that have scope |
34 commentList = [c for c in commentList if not c.is_reply()] |
34 commentList = [c for c in commentList if not c.is_reply() and not c.is_scope_removed()] |
35 |
35 |
36 for comment in commentList: |
36 for comment in commentList: |
37 try: |
37 try: |
38 comment.initial_start_offset = span_starts_previous[comment.start_wrapper] + comment.start_offset |
38 comment.initial_start_offset = span_starts_previous[comment.start_wrapper] + comment.start_offset |
39 comment.initial_end_offset = span_starts_previous[comment.end_wrapper] + comment.end_offset |
39 comment.initial_end_offset = span_starts_previous[comment.end_wrapper] + comment.end_offset |
138 if with_colors and color != 0 : |
138 if with_colors and color != 0 : |
139 ret = "<span style='background-color:%s;'>%s</span>"%(BCKCOLORS[color], ret) |
139 ret = "<span style='background-color:%s;'>%s</span>"%(BCKCOLORS[color], ret) |
140 |
140 |
141 return ret |
141 return ret |
142 |
142 |
143 # comments are comments and replies : TODO $$$$$$$$$$$$ handle replies case |
143 # comments are comments and replies : |
144 def insert_comment_markers(htmlcontent, comments, with_markers, with_colors) : |
144 def insert_comment_markers(htmlcontent, comments, with_markers, with_colors) : |
145 |
145 |
146 # parser = html5lib.HTMLParser(tree=treebuilders.getTreeBuilder("beautifulsoup")) |
146 # parser = html5lib.HTMLParser(tree=treebuilders.getTreeBuilder("beautifulsoup")) |
147 # html = parser.parse(htmlcontent.encode("utf8"), encoding="utf8") |
147 # html = parser.parse(htmlcontent.encode("utf8"), encoding="utf8") |
148 html = get_the_soup(htmlcontent) ; |
148 html = get_the_soup(htmlcontent) ; |