Skip to content

Embed GitHub source code into a web-page like a Gist.

License

Notifications You must be signed in to change notification settings

cdm/github-embed

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

github-embed

Embed GitHub source code into a web-page like a Gist.

Features

  • Embed GitHub source code file into a web-page
  • Display only selected lines passed in query string
  • Display dynamic code section using special identifier
  • Customisable colour schemes
  • Display line numbers

How to use this script

Host embed.js and 404.html on a web server, or bundle with a local web project. A service like netlify will be ideal.

Visit 404.html in a web browser and configure the GitHub code URL you wish to preview like a gist.


Alternatively, host embed.js and use it as follows:

<body>
   <script src="./embed.js?target=https%3A%2F%2Fgithub.com%2Fyour-username%2Fyour-repo%2Fblob%2Fmaster%2Fexample.py&style=gradient-dark&hideFileMeta=off"></script>
</body>

Background

This script was adapted from the work by yusanshi and altered to match the requirements for embedding code in Vega documentation. It is shared open-source under the MIT license.

About

Embed GitHub source code into a web-page like a Gist.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 63.6%
  • JavaScript 36.4%