1
0
mirror of https://github.com/ryanoasis/nerd-fonts.git synced 2024-12-25 20:18:01 +02:00
nerd-fonts/bin/scripts/update-all-contributors-website.py
Fini Jastrow a78dcd7fdb Improve created Contributors web-page
[why]
When viewed on a small screens the contributors page on the gh-pages
looks not very nice and overflows.

[how]
Instead of a table with a predefined number of rows we just use blocks
in an inline context that allows the line break to adjust to the
available width.

Fixes: #1399

Reported-by: Vitthal Gund <@VitthalGund>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-11-01 17:20:38 +01:00

45 lines
1.8 KiB
Python
Executable File

#!/usr/bin/env python3
import fileinput
import string
import re
print("* reading CONTRIBUTORS.md")
file = open("../../CONTRIBUTORS.md", "r")
contributorContents = file.read()
file.close()
print("* reading post")
file = open("../../_posts/2017-01-05-all-contributors.md", "r")
webContributorContents = file.read()
file.close()
print("* find fences")
starting_text = '<!-- UPDATE START -->'
ending_text = '<!-- UPDATE END -->'
wCC_start = webContributorContents.find(starting_text) + len(starting_text)
wCC_end = webContributorContents.rfind(ending_text)
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)
transformedContributorContents = contributorContents[cC_start:cC_end]
print('* replacing table')
transformedContributorContents = transformedContributorContents.replace('<img src=', '<img class="lzy_img" data-src=')
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)
print('* final out')
webContributorContents = (webContributorContents[:wCC_start]
+ "\n" + transformedContributorContents
+ "\n" + webContributorContents[wCC_end:])
file = open("../../_posts/2017-01-05-all-contributors.md", "w")
file.write(webContributorContents)
file.close()