--- ValBot/Python/check_intrawiki_section_links.py 2023/08/15 02:03:16 1185 +++ ValBot/Python/check_intrawiki_section_links.py 2024/09/16 23:08:26 1192 @@ -35,7 +35,7 @@ chapter_names = ['CHAPTER_00_._COMBAT_TR # Tuple of patterns for recognizing wikilinks # Pattern 1: Detect "[[anything]]", "[[any:thing]]", "[[any|thing]]", "[[any:thi|ng]]" # Pattern 2: Detect "{{SectionLink|Page|Section name}}", "{{SectionLink||Section name}}" -link_patterns = ("\[\[[^|\]]*(\||\])", "\{\{SectionLink\|[^|\}]*\|[^|\}]*\}\}") +link_patterns = (r"\[\[[^|\]]*(\||\])", r"\{\{SectionLink\|[^|\}]*\|[^|\}]*\}\}") # Initialize globals debug = 0 @@ -64,9 +64,6 @@ def find_section(page_text, page_name, p target_page_name_human = target_page_name.replace('_', ' ') if debug: pywikibot.stdout(' Searching for section link {} on page.'.format(anchor_name)) - # Convert slash character to the dot-notation hex encoding that MediaWiki uses - anchor_name = anchor_name.replace('/', '.2F') - # Read linked page to see if it really has this anchor link soup = BeautifulSoup(page_text, 'html.parser') found_section = False @@ -86,7 +83,7 @@ def find_section(page_text, page_name, p break if found_section == False: possibly_print(page_name) - pywikibot.stdout(' ERROR: Could not find section "{0}" on page {1}!'.format(anchor_name, pre_section)) + pywikibot.stdout(' ERROR: Could not find section "{0}" on page {1}!'.format(anchor_name, target_page_name_human)) errors_issued += 1 elif debug and print_result: pywikibot.stdout(' The section "{0}" was found on page "{1}".'.format(anchor_name, target_page_name_human))