Created
March 3, 2022 16:47
-
-
Save adam-binks/a592008c45f781c144e76ce916c73316 to your computer and use it in GitHub Desktop.
Generate GuidedTrack code to invisibly load all a program's images on its first page, so that they load instantly on later pages
This file contains hidden or 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
# NB: you may need to convert tabs to spaces when you copy it into your GT program | |
gt_program = r"""copy and paste your program here>""" | |
lines = gt_program.split('\n') | |
images = [] | |
for command in ["*image: ", "\t\t*picture: "]: | |
images.extend([line[len(command):] for line in lines if line.startswith(command)]) | |
print(r""" | |
*html | |
<style> | |
.imagesToPreload { | |
display:none; | |
} | |
</style> | |
*component | |
*classes: imagesToPreload | |
""") | |
print("\n".join("\t*image: " + image for image in images)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment