forked from ryanoasis/nerd-fonts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a very basic script to update all contributors section on the we…
…bsite
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import fileinput | ||
import string | ||
import re | ||
|
||
file = open("../../CONTRIBUTORS.md", "r") | ||
contributorContents = file.read() | ||
file.close() | ||
|
||
# print(contributorContents) | ||
|
||
|
||
file = open("/home/ryan/projects/nerd-fonts-gh-pages/_posts/2017-01-05-all-contributors.md", "r") | ||
webContributorContents = file.read() | ||
file.close() | ||
|
||
# print(webContributorContents) | ||
|
||
# search and replace | ||
starting_text = '<!-- UPDATE START -->' | ||
ending_text = '<!-- UPDATE END -->' | ||
to_replace = webContributorContents[webContributorContents.find(starting_text)+len(starting_text):webContributorContents.rfind(ending_text)] | ||
|
||
print('re replace') | ||
print('-------------------------------------------------') | ||
print(to_replace) | ||
|
||
# Remove markdown that won't work as-is in the jekyll page: | ||
transformedContributorContents = re.sub('[![All Contributors](.*)\(#contributors\)\n', '', contributorContents) | ||
transformedContributorContents = re.sub('Thanks goes to these wonderful people(.*):\n', '', transformedContributorContents) | ||
transformedContributorContents = string.replace(transformedContributorContents, '## Contributors\n\n', '') | ||
transformedContributorContents = string.replace(transformedContributorContents, 'This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!', '') | ||
|
||
# Fix the formatting for the grid table: | ||
transformedContributorContents = string.replace(transformedContributorContents, ' [<img src=', '\n<div markdown="1">\n[<img class="lzy_img" data-src=') | ||
transformedContributorContents = string.replace(transformedContributorContents, '") |', '")\n</div>') | ||
transformedContributorContents = string.replace(transformedContributorContents, '| :---: | :---: | :---: | :---: | :---: | :---: | :---: |', '') | ||
transformedContributorContents = string.replace(transformedContributorContents, '<!-- ALL-CONTRIBUTORS-LIST:END -->', '') | ||
transformedContributorContents = string.replace(transformedContributorContents, '|\n', '') # @TODO fixme | ||
|
||
|
||
print('transformed contr contents') | ||
print('-------------------------------------------------') | ||
print(transformedContributorContents) | ||
|
||
webContributorContents = string.replace(webContributorContents, to_replace, transformedContributorContents) | ||
|
||
print('final out') | ||
print('-------------------------------------------------') | ||
print(webContributorContents) | ||
|
||
|
||
# write the updated all contributors to the website | ||
file = open("/home/ryan/projects/nerd-fonts-gh-pages/_posts/2017-01-05-all-contributors.md", "w") | ||
file.write(webContributorContents) |