docs: def link_map(
          self,
          format="~2~",
          url=None,
          show_if_single_page=False,
          separator=" ",
          symbol_first="&lt;&lt;",
          symbol_last="&gt;&gt;",
          symbol_previous="&lt;",
          symbol_next="&gt;",
          link_attr=None,
          curpage_attr=None,
          dotdot_attr=None,
      ):
          """ Return map with links to other pages if default pager() function is not suitable solution.
          format:
              Format string that defines how the pager would be normally rendered rendered. Uses same arguments as pager()
              method, but returns a simple dictionary in form of:
              {'current_page': {'attrs': {},
                                       'href': 'http://example.org/foo/page=1',
                                       'value': 1},
                      'first_page': {'attrs': {},
                                     'href': 'http://example.org/foo/page=1',
                                     'type': 'first_page',
                                     'value': 1},
                      'last_page': {'attrs': {},
                                    'href': 'http://example.org/foo/page=8',
                                    'type': 'last_page',
                                    'value': 8},
                      'next_page': {'attrs': {}, 'href': 'HREF', 'type': 'next_page', 'value': 2},
                      'previous_page': None,
                      'range_pages': [{'attrs': {},
                                       'href': 'http://example.org/foo/page=1',
                                       'type': 'current_page',
                                       'value': 1},
                                       ....
                                      {'attrs': {}, 'href': '', 'type': 'span', 'value': '..'}]}
  
  
              The string can contain the following $-tokens that are substituted by the
              string.Template module:
  
              - $first_page: number of first reachable page
              - $last_page: number of last reachable page
              - $page: number of currently selected page
              - $page_count: number of reachable pages
              - $items_per_page: maximal number of items per page
              - $first_item: index of first item on the current page
              - $last_item: index of last item on the current page
              - $item_count: total number of items
              - $link_first: link to first page (unless this is first page)
              - $link_last: link to last page (unless this is last page)
              - $link_previous: link to previous page (unless this is first page)
              - $link_next: link to next page (unless this is last page)
  
              To render a range of pages the token '~3~' can be used. The
              number sets the radius of pages around the current page.
              Example for a range with radius 3:
  
              '1 .. 5 6 7 [8] 9 10 11 .. 50'
  
              Default: '~2~'
  
          url
              The URL that page links will point to. Make sure it contains the string
              $page which will be replaced by the actual page number.
              Must be given unless a url_maker is specified to __init__, in which
              case this parameter is ignored.
  
          symbol_first
              String to be displayed as the text for the $link_first link above.
  
              Default: '&lt;&lt;' (<<)
  
          symbol_last
              String to be displayed as the text for the $link_last link above.
  
              Default: '&gt;&gt;' (>>)
  
          symbol_previous
              String to be displayed as the text for the $link_previous link above.
  
              Default: '&lt;' (<)
  
          symbol_next
              String to be displayed as the text for the $link_next link above.
  
              Default: '&gt;' (>)
  
          separator:
              String that is used to separate page links/numbers in the above range of pages.
  
              Default: ' '
  
          show_if_single_page:
              if True the navigator will be shown even if there is only one page.
  
              Default: False
  
          link_attr (optional)
              A dictionary of attributes that get added to A-HREF links pointing to other pages. Can
              be used to define a CSS style or class to customize the look of links.
  
              Example: { 'style':'border: 1px solid green' }
              Example: { 'class':'pager_link' }
  
          curpage_attr (optional)
              A dictionary of attributes that get added to the current page number in the pager (which
              is obviously not a link). If this dictionary is not empty then the elements will be
              wrapped in a SPAN tag with the given attributes.
  
              Example: { 'style':'border: 3px solid blue' }
              Example: { 'class':'pager_curpage' }
  
          dotdot_attr (optional)
              A dictionary of attributes that get added to the '..' string in the pager (which is
              obviously not a link). If this dictionary is not empty then the elements will be wrapped
              in a SPAN tag with the given attributes.
  
              Example: { 'style':'color: #808080' }
              Example: { 'class':'pager_dotdot' }
          """
          link_attr = link_attr or {}
          curpage_attr = curpage_attr or {}
          dotdot_attr = dotdot_attr or {}
          self.curpage_attr = curpage_attr
          self.separator = separator
          self.link_attr = link_attr
          self.dotdot_attr = dotdot_attr
          self.url = url
  
          regex_res = re.search(r"~(\d+)~", format)
          if regex_res:
              radius = regex_res.group(1)
          else:
              radius = 2
          radius = int(radius)
          self.radius = radius
  
          # Compute the first and last page number within the radius
          # e.g. '1 .. 5 6 [7] 8 9 .. 12'
          # -> leftmost_page  = 5
          # -> rightmost_page = 9
          leftmost_page = (
              max(self.first_page, (self.page - radius)) if self.first_page else None
          )
          rightmost_page = (
              min(self.last_page, (self.page + radius)) if self.last_page else None
          )
  
          nav_items = {
              "first_page": None,
              "last_page": None,
              "previous_page": None,
              "next_page": None,
              "current_page": None,
              "radius": self.radius,
              "range_pages": [],
          }
  
          if leftmost_page is None or rightmost_page is None:
              return nav_items
  
          nav_items["first_page"] = {
              "type": "first_page",
              "value": unicode(symbol_first),
              "attrs": self.link_attr,
              "number": self.first_page,
              "href": self.url_maker(self.first_page),
          }
  
          # Insert dots if there are pages between the first page
          # and the currently displayed page range
          if leftmost_page - self.first_page > 1:
              # Wrap in a SPAN tag if dotdot_attr is set
              nav_items["range_pages"].append(
                  {
                      "type": "span",
                      "value": "..",
                      "attrs": self.dotdot_attr,
                      "href": "",
                      "number": None,
                  }
              )
  
          for thispage in range(leftmost_page, rightmost_page + 1):
              # Highlight the current page number and do not use a link
              if thispage == self.page:
                  # Wrap in a SPAN tag if curpage_attr is set
                  nav_items["range_pages"].append(
                      {
                          "type": "current_page",
                          "value": unicode(thispage),
                          "number": thispage,
                          "attrs": self.curpage_attr,
                          "href": self.url_maker(thispage),
                      }
                  )
                  nav_items["current_page"] = {
                      "value": thispage,
                      "attrs": self.curpage_attr,
                      "type": "current_page",
                      "href": self.url_maker(thispage),
                  }
              # Otherwise create just a link to that page
              else:
                  nav_items["range_pages"].append(
                      {
                          "type": "page",
                          "value": unicode(thispage),
                          "number": thispage,
                          "attrs": self.link_attr,
                          "href": self.url_maker(thispage),
                      }
                  )
  
          # Insert dots if there are pages between the displayed
          # page numbers and the end of the page range
          if self.last_page - rightmost_page > 1:
              # Wrap in a SPAN tag if dotdot_attr is set
              nav_items["range_pages"].append(
                  {
                      "type": "span",
                      "value": "..",
                      "attrs": self.dotdot_attr,
                      "href": "",
                      "number": None,
                  }
              )
  
          # Create a link to the very last page (unless we are on the last
          # page or there would be no need to insert '..' spacers)
          nav_items["last_page"] = {
              "type": "last_page",
              "value": unicode(symbol_last),
              "attrs": self.link_attr,
              "href": self.url_maker(self.last_page),
              "number": self.last_page,
          }
  
          nav_items["previous_page"] = {
              "type": "previous_page",
              "value": unicode(symbol_previous),
              "attrs": self.link_attr,
              "number": self.previous_page or self.first_page,
              "href": self.url_maker(self.previous_page or self.first_page),
          }
  
          nav_items["next_page"] = {
              "type": "next_page",
              "value": unicode(symbol_next),
              "attrs": self.link_attr,
              "number": self.next_page or self.last_page,
              "href": self.url_maker(self.next_page or self.last_page),
          }
  
          return nav_items