diff --git a/command-line/update.py b/command-line/update.py index 9c8bade..3152388 100644 --- a/command-line/update.py +++ b/command-line/update.py @@ -4,6 +4,8 @@ import re import json import jinja2 +# Notes are here: https://pad.vvvvvvaria.org/volumetric-regimes-in-process. + STATIC_FOLDER_PATH = '.' # without trailing slash PUBLIC_STATIC_FOLDER_PATH = '.' # without trailing slash TEMPLATES_DIR = './templates' @@ -93,20 +95,12 @@ def download_media(html, images, wiki): img_path_patterns = [rf'(? { image_path }') # for debugging: each image should have the correct match! html = html.replace(match, image_path) replaced.append(match) - # else: - # print(' already replaced!') - # print('\n------\n') - # break - # else: - # print(' no match!') - # print('\n------\n') return html @@ -119,10 +113,10 @@ def add_item_inventory_links(html): matches = re.findall(r'\w.*?Item \d\d\d.*?\w\w\w', html) # Dodgy attempt to find unique patterns for each mentioning of Item ### index = {} for match in matches: - item_match = re.search(r'Item \d\d\d', match) - item = item_match.group() - number = item.replace('Item ', '').strip() - text = match.replace(f'Item { number }', '') + item_match = re.search(r'Item \d\d\d', match).group() + number = item_match.replace('Item ', '').strip() + text_before = re.search(rf'\w.*?Item { number }', match).group().replace(f'Item { number }', '') + text_after = re.search(rf'Item { number }.*?\w\w\w', match).group().replace(f'Item { number }', '') if not number in index: index[number] = [] count = 1 @@ -130,8 +124,8 @@ def add_item_inventory_links(html): count = index[number][-1] + 1 index[number].append(count) item_id = f'ii-{ number }-{ index[number][-1] }' - print(f'match: { number } --> { item_id } --> { text }') - html = html.replace(match, f'Item { number }{ text }') + # print(f'match: { number } --> { item_id } --> { match }') + html = html.replace(match, f'{ text_before }Item { number }{ text_after }') # IN THE ITEM INDEX # Also add a around the index nr to style it @@ -209,17 +203,6 @@ def tweaking(html): for match in results: html = html.replace(match, f'
{ match }
') - # for result in results: - # print(result) - # print('---') - # print('---') - # print('AANTAL:', len(results)) - # print('SET LEN:', len(set(results))) - # print('---') - - # html = html.replace('
', f'
') # add Multi Remix as SVG - # html = html.replace('', '') - return html def clean_up(html):