Skip to content

ahluntang/file-embeds

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

File Embeds

About

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.

Usage

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>

Credits

Thanks to Lea Verou for making prism. Check prism for syntax highlighting.

Contribute

If there are any problems or suggestions, don't hesitate to create an issue or send a pull request.

About

Javascript library that embeds code files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published