Javascript library that embeds code files in a <pre><code> </code></pre>
tags.
It also detects GitHub links and uses the GitHub API.
NOTE: in some cases GitHub blocks javascript file fetching through raw.github.com. In that case, use the link from the main GitHub domain as shown in the usage section.
I was inspired by the clean file inclusion plugin Lea Verou made for prism. This code reuses the structure of that plugin but has a special case for GitHub links because files from GitHub needs to be fetched through the GitHub API.
Include the script in the body.
<script type="text/javascript" src="file-embeds.js"></script>
Add a link to your GitHub file using the data-src
attribute in the pre tag.
<pre data-src="https://github.com/ahluntang/file-embeds/blob/master/file-embeds.js"></pre>
Thanks to Lea Verou for making prism. Check prism for syntax highlighting.
If there are any problems or suggestions, don't hesitate to create an issue or send a pull request.