docs: def account_for_stripped_whitespace(spaces_keys,
                                      removed_spaces,
                                      replacement_types,
                                      len_reportnums,
                                      journals_matches,
                                      replacement_index):
      """To build a processed (MARC XML) reference line in which the
         recognised citations such as standardised periodical TITLEs and
         REPORT-NUMBERs have been marked up, it is necessary to read from
         the reference line BEFORE all punctuation was stripped and it was
         made into upper-case. The indices of the cited items in this
         'original line', however, will be different to those in the
         'working-line', in which punctuation and multiple-spaces were
         stripped out. For example, the following reading-line:
  
          [26] E. Witten and S.-T. Yau, hep-th/9910245.
         ...becomes (after punctuation and multiple white-space stripping):
          [26] E WITTEN AND S T YAU HEP TH/9910245
  
         It can be seen that the report-number citation (hep-th/9910245) is
         at a different index in the two strings. When refextract searches
         for this citation, it uses the 2nd string (i.e. that which is
         capitalised and has no punctuation). When it builds the MARC XML
         representation of the reference line, however, it needs to read from
         the first string. It must therefore consider the whitespace,
         punctuation, etc that has been removed, in order to get the correct
         index for the cited item. This function accounts for the stripped
         characters before a given TITLE or REPORT-NUMBER index.
         @param spaces_keys: (list) - the indices at which spaces were
          removed from the reference line.
         @param removed_spaces: (dictionary) - keyed by the indices at which
          spaces were removed from the line, the values are the number of
          spaces actually removed from that position.
          So, for example, "3 spaces were removed from position 25 in
          the line."
         @param replacement_types: (dictionary) - at each 'replacement_index'
          in the line, the of replacement to make (title or reportnumber).
         @param len_reportnums: (dictionary) - the lengths of the REPORT-
          NUMBERs matched at the various indices in the line.
         @param len_titles: (dictionary) - the lengths of the various
          TITLEs matched at the various indices in the line.
         @param replacement_index: (integer) - the index in the working line
          of the identified TITLE or REPORT-NUMBER citation.
         @return: (tuple) containing 2 elements:
                          + the true replacement index of a replacement in
                            the reading line;
                          + any extras to add into the replacement index;
      """
      extras = 0
      true_replacement_index = replacement_index
      spare_replacement_index = replacement_index
  
      for space in spaces_keys:
          if space < true_replacement_index:
              # There were spaces stripped before the current replacement
              # Add the number of spaces removed from this location to the
              # current replacement index:
              true_replacement_index += removed_spaces[space]
              spare_replacement_index += removed_spaces[space]
          elif space >= spare_replacement_index and \
              replacement_types[replacement_index] == u"journal" and \
              space < (spare_replacement_index +
                       len(journals_matches[replacement_index])):
              # A periodical title is being replaced. Account for multi-spaces
              # that may have been stripped from the title before its
              # recognition:
              spare_replacement_index += removed_spaces[space]
              extras += removed_spaces[space]
          elif space >= spare_replacement_index and \
              replacement_types[replacement_index] == u"reportnumber" and \
              space < (spare_replacement_index +
                       len_reportnums[replacement_index]):
              # An institutional preprint report-number is being replaced.
              # Account for multi-spaces that may have been stripped from it
              # before its recognition:
              spare_replacement_index += removed_spaces[space]
              extras += removed_spaces[space]
  
      # return the new values for replacement indices with stripped
      # whitespace accounted for:
      return true_replacement_index, extras