Created
August 19, 2022 07:23
-
-
Save kenpos/9ccaf29dd315ce6c472935e2405bd858 to your computer and use it in GitHub Desktop.
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
import glob | |
import re | |
def main(): | |
print("START") | |
l = glob.glob('*.md') | |
for file in l: | |
print(file) | |
with open(file, encoding="utf-8") as f: | |
data_lines = f.read() | |
data_lines = data_lines.replace("![](images", '{{< figure src="/images') | |
data_lines = data_lines.replace(".png)", '.png" title="" class="center" width="320" height="640" >}}') | |
data_lines = data_lines.replace(".jpg)", '.jpg" title="" class="center" width="320" height="640" >}}') | |
data_lines = data_lines.replace(".gif)", '.gif" title="" class="center" width="320" height="640" >}}') | |
data_lines = data_lines.replace('width="320"', 'width="600"') | |
data_lines = data_lines.replace('height="640"', 'height="320"') | |
with open(file, mode="w", encoding="utf-8") as f: | |
f.write(data_lines) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
convert script