Skip to content

Commit 54bc834

Browse files
committed
Add MOS: to block list and handle links to named anchors.
1 parent b991e55 commit 54bc834

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

extract_outbound_links.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,34 @@ def extract_outbound_links(topic_slug):
2828
# Collect each unique link to another wiki topic.
2929
linked_slugs = {}
3030
order_index = 0
31-
block_list = ['file:', 'help:', 'talk:', 'template:', 'wikipedia:']
31+
block_list = [
32+
'file:',
33+
'help:',
34+
'mos:',
35+
'talk:',
36+
'template:',
37+
'wikipedia:'
38+
]
3239

3340
for link in article_body_links:
3441
link_href = str(link.get('href'))
3542

3643
if link_href[0:6] == '/wiki/':
3744
current_link_slug = link_href[6:]
45+
46+
# Handle links to named anchors.
47+
if '#' in current_link_slug:
48+
new_current_link_slug = current_link_slug.split('#')[0]
49+
current_link_slug = new_current_link_slug
50+
51+
# Handle links to a type of page on the block list.
3852
current_link_slug_contains_block_list_item = False
3953

4054
for item in block_list:
4155
if item in current_link_slug.lower():
4256
current_link_slug_contains_block_list_item = True
4357

58+
# Process valid links.
4459
if current_link_slug not in linked_slugs.keys() \
4560
and not current_link_slug_contains_block_list_item:
4661
linked_slugs[current_link_slug] = {

0 commit comments

Comments
 (0)