docs: def cal_position(self, text, has_toplinks, has_bottomlinks, head_len, head_start):
          """
          Calculate the position of toplinks and bottomlinks, if there is not
          toplinks and bottomlinks then toplinks position will be the position after <head>
          and if there is no bottomlinks, the bottomlinks position will be the
          position before </head>.
          """
          if head_len == 0:
              top_start = top_end = bottom_start = bottom_end = 0
          else:
              top_start = top_end = head_start + 6
              bottom_start = bottom_end = head_start + head_len - 7
              
          if has_toplinks:
              t = r_top.search(text)
              if t:
                  top_start, top_end = t.span()
          
          if has_bottomlinks:
              t = r_bottom.search(text)
              if t:
                  bottom_start, bottom_end = t.span()
  
          return top_end, bottom_end