import regex

from righter.competitor.wikipedia_typos import typos
from bs4 import BeautifulSoup


def _load_regexes():
    regexes = []
    soup = BeautifulSoup(typos, 'html.parser')
    for typo in soup.findAll("typo"):
        regexes.append(regex.compile(typo.attrs["find"]))
    return regexes


regexes = _load_regexes()


def check(text):
    changes = []
    for re in regexes:
        for match in re.finditer(text):
            start = match.start()
            changes.append({
                'start': start,
                'selection': text[start:match.end()]
            })
    return changes

@@ -453,16 +453,88 @@
 start()%0A
+            if all(start != change%5B'start'%5D for change in changes):%0A    
         
@@ -570,16 +570,20 @@
         
+  
+  
 'start':
@@ -590,16 +590,20 @@
  start,%0A
+    
         
@@ -647,16 +647,20 @@
 .end()%5D%0A
+    
         

Fix wikipedia bug