| 35 |
|
# Tuple of patterns for recognizing wikilinks |
| 36 |
|
# Pattern 1: Detect "[[anything]]", "[[any:thing]]", "[[any|thing]]", "[[any:thi|ng]]" |
| 37 |
|
# Pattern 2: Detect "{{SectionLink|Page|Section name}}", "{{SectionLink||Section name}}" |
| 38 |
< |
link_patterns = ("\[\[[^|\]]*(\||\])", "\{\{SectionLink\|[^|\}]*\|[^|\}]*\}\}") |
| 38 |
> |
link_patterns = (r"\[\[[^|\]]*(\||\])", r"\{\{SectionLink\|[^|\}]*\|[^|\}]*\}\}") |
| 39 |
|
|
| 40 |
|
# Initialize globals |
| 41 |
|
debug = 0 |
| 64 |
|
target_page_name_human = target_page_name.replace('_', ' ') |
| 65 |
|
if debug: pywikibot.stdout(' Searching for section link {} on page.'.format(anchor_name)) |
| 66 |
|
|
| 67 |
– |
# Convert slash character to the dot-notation hex encoding that MediaWiki uses |
| 68 |
– |
anchor_name = anchor_name.replace('/', '.2F') |
| 69 |
– |
|
| 67 |
|
# Read linked page to see if it really has this anchor link |
| 68 |
|
soup = BeautifulSoup(page_text, 'html.parser') |
| 69 |
|
found_section = False |