src/cm/utils/comment_positioning.py
changeset 58 a480a91d63ca
parent 0 40c8f766c9b8
child 103 61fd17f9ab78
equal deleted inserted replaced
57:b32aa76ee411 58:a480a91d63ca
   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) ;
   149     
   149     
   150 #    import pdb;pdb.set_trace()
   150 #    import pdb;pdb.set_trace()
   151     
   151     if comments :
   152     max_wrapper = max([comment.end_wrapper for comment in comments])
   152         max_wrapper = max([comment.end_wrapper for comment in comments])
   153     min_wrapper = min([comment.start_wrapper for comment in comments])
   153         min_wrapper = min([comment.start_wrapper for comment in comments])
   154     
   154         
   155     datas = {} # { wrapper_id : {'start_color':nb_of_comments_unterminated_at_wrapper_start, 'offsets':{offset: [[ids of wrappers starting at offset], [ids of wrappers ending at offset]]}}
   155     datas = {} # { wrapper_id : {'start_color':nb_of_comments_unterminated_at_wrapper_start, 'offsets':{offset: [[ids of wrappers starting at offset], [ids of wrappers ending at offset]]}}
   156     # datas['offsets'][someoffset][0] and idem[1] will be ordered the way comments are (should be ('start_wrapper', 'start_offset', 'end_wrapper', 'end_offset') important)
   156     # datas['offsets'][someoffset][0] and idem[1] will be ordered the way comments are (should be ('start_wrapper', 'start_offset', 'end_wrapper', 'end_offset') important)
   157     cpt = 1 # starting numbered comment
   157     cpt = 1 # starting numbered comment
   158     for comment in comments :
   158     for comment in comments :
   159         if comment.is_reply() :
   159         if comment.is_reply() :