Skip to content

Instantly share code, notes, and snippets.

@robstenzinger
Created April 1, 2014 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robstenzinger/9906572 to your computer and use it in GitHub Desktop.
Save robstenzinger/9906572 to your computer and use it in GitHub Desktop.
"""
Post-build update a revealJS deck
- adds a base target, jQuery, and a main.js include script block
technique from:
http://stackoverflow.com/questions/39086/search-and-replace-a-line-in-a-file-in-python
"""
import fileinput
import sys
def replaceAll(file,searchExp,replaceExp):
for line in fileinput.input(file, inplace=1):
if searchExp in line:
line = line.replace(searchExp,replaceExp)
sys.stdout.write(line)
replaceAll("deck.html", """<script src="reveal.js/js/reveal.min.js"></script>""", """<script src="reveal.js/js/reveal.min.js"></script><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script><script src="js/main.js"></script><base target="_blank">""")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment