file_name = "Week 0 - Greetings.slides.html"
out_name = "Week 0 - Summer Greetings.slides.html"
with open(file_name, 'r') as f:
slides = f.read()
lines = slides.splitlines()
catch = '<div class="fragment" data-fragment-index="4">'
skip = [0] # instance of fragments that are to be kept
output = []
caught = 0
for line in lines:
if catch in line.lower():
if caught not in skip:
output.append(line.replace(catch,'<div>'))
else:
output.append(line)
caught +=1
else:
output.append(line)
print('caught %d instances'%(caught))
with open(out_name, 'w') as f:
f.write('\n'.join(output))