Created
December 31, 2017 11:37
-
-
Save durgaswaroop/dd9dcb1e592751c1aced5f0f42aeedc1 to your computer and use it in GitHub Desktop.
Modifications needed to be done on html generated by pandoc for blogger
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 sys | |
import os | |
import fileinput | |
# alias modifications="python ~/Desktop/30DaysOfBlogging/modifications.py" | |
# Run the script with `modifications <markdown file>` | |
def modify(html_file): | |
# If file doesnot exist, just exit | |
if not os.path.exists(html_file): | |
print("ERROR: HTML file '" + html_file + "' does not exist. Exiting") | |
sys.exit() | |
full_file = open(html_file).read() | |
modified_file = full_file.replace('<pre><code>', '<pre class="prettyprint">').replace('</code></pre>', '</pre>') | |
with open(html_file, 'w') as file: | |
file.write(modified_file) | |
if __name__ == '__main__': | |
# One argument, which is the name of the html file | |
if len(sys.argv) is not 2: | |
print("ERROR: One and only one argument needed. Html file") | |
sys.exit() | |
html_file = sys.argv[1] | |
modify(html_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment