2023-01-27 16:10:38 +02:00
|
|
|
#!/usr/bin/env python3
|
2020-04-06 10:02:09 +02:00
|
|
|
import fileinput
|
|
|
|
import string
|
|
|
|
import re
|
|
|
|
|
2023-01-27 16:10:38 +02:00
|
|
|
print("* reading CONTRIBUTORS.md")
|
2020-04-06 10:02:09 +02:00
|
|
|
file = open("../../CONTRIBUTORS.md", "r")
|
|
|
|
contributorContents = file.read()
|
|
|
|
file.close()
|
|
|
|
|
2023-01-27 16:10:38 +02:00
|
|
|
print("* reading post")
|
|
|
|
file = open("../../_posts/2017-01-05-all-contributors.md", "r")
|
2020-04-06 10:02:09 +02:00
|
|
|
webContributorContents = file.read()
|
|
|
|
file.close()
|
|
|
|
|
2023-01-27 16:10:38 +02:00
|
|
|
print("* find fences")
|
2020-04-06 10:02:09 +02:00
|
|
|
starting_text = '<!-- UPDATE START -->'
|
|
|
|
ending_text = '<!-- UPDATE END -->'
|
2023-01-27 16:10:38 +02:00
|
|
|
wCC_start = webContributorContents.find(starting_text) + len(starting_text)
|
|
|
|
wCC_end = webContributorContents.rfind(ending_text)
|
2020-04-06 10:02:09 +02:00
|
|
|
|
2023-01-27 16:10:38 +02:00
|
|
|
starting_text = '<!-- ALL-CONTRIBUTORS-LIST:START '
|
|
|
|
ending_text = '<!-- ALL-CONTRIBUTORS-LIST:END -->'
|
|
|
|
cC_start = contributorContents.find(starting_text)
|
|
|
|
cC_end = contributorContents.rfind(ending_text) + len(ending_text)
|
2020-04-06 10:02:09 +02:00
|
|
|
|
2023-01-27 16:10:38 +02:00
|
|
|
transformedContributorContents = contributorContents[cC_start:cC_end]
|
2020-04-06 10:02:09 +02:00
|
|
|
|
2023-11-01 17:54:38 +02:00
|
|
|
print('* replacing table')
|
2023-01-27 16:10:38 +02:00
|
|
|
transformedContributorContents = transformedContributorContents.replace('<img src=', '<img class="lzy_img" data-src=')
|
2023-11-01 17:54:38 +02:00
|
|
|
transformedContributorContents = re.sub(' *</?table>', '', transformedContributorContents, flags=re.IGNORECASE)
|
|
|
|
transformedContributorContents = re.sub(' *</?tbody>', '', transformedContributorContents, flags=re.IGNORECASE)
|
|
|
|
transformedContributorContents = re.sub(' *</?tr>', '', transformedContributorContents, flags=re.IGNORECASE)
|
|
|
|
transformedContributorContents = re.sub(' *</td>', '</span>', transformedContributorContents, flags=re.IGNORECASE)
|
|
|
|
transformedContributorContents = re.sub(' *<td[^>]*>', '<span style="display: inline-block; width: 130px;">', transformedContributorContents, flags=re.IGNORECASE)
|
2020-04-06 10:02:09 +02:00
|
|
|
|
2023-01-27 16:10:38 +02:00
|
|
|
print('* final out')
|
|
|
|
webContributorContents = (webContributorContents[:wCC_start]
|
|
|
|
+ "\n" + transformedContributorContents
|
|
|
|
+ "\n" + webContributorContents[wCC_end:])
|
2020-04-06 10:02:09 +02:00
|
|
|
|
2023-01-27 16:10:38 +02:00
|
|
|
file = open("../../_posts/2017-01-05-all-contributors.md", "w")
|
2020-04-06 10:02:09 +02:00
|
|
|
file.write(webContributorContents)
|
2023-01-27 16:10:38 +02:00
|
|
|
file.close()
|