Emgithub
Embed a file from GitHub repository just like GitHub Gist.
Install / Use
/learn @yusanshi/EmgithubREADME
emgithub
https://emgithub.com/
Embed a file from GitHub repository just like GitHub Gist.
Demo: https://yusanshi.com/posts/2019-12-17/emgithub/#%E6%B5%8B%E8%AF%95.

Get started
There are two ways to use the service:
- Go to https://emgithub.com/ and paste the URL.
- Open a file in GitHub and simply add "em" before "github.com" in the address bar.
ProTip
- Support permanent links to a file or a code snippet (use
#to slice code). - Specify TAB width with
?ts=. Note when used together with code slicing, you should combine them like this:?ts=2#L4-L12. - Support Markdown (
*.md) and Jupyter Notebook (*.ipynb) rendering. - Support
<script>and<iframe>embedding. Generally the<script>should be preferred for being more lightweight. But if your platform doesn't support<script>embedding (the case with Obsidian), or the snippets look strange when embedded into the target web page (most likely the styles are overridden by the target page), you can try the<iframe>embedding.
Development
You can modify the code and test it by launching an HTTP server in the project directory.
-
Launch an HTTP server.
git clone https://github.com/yusanshi/emgithub cd emgithub python -m http.server 8086 -
Make the changes.
-
Visit http://localhost:8086/404.html.
Don't be confused by the "404". It is how the "adding em in the address bar" works: after adding the "em", the HTTP server (provided by GitHub Pages) can't find the file so it renders
404.html. Then in the 404 page, the target file is extracted from the URL.
Create your own emgithub
You may want to create your own emgithub for some reasons, like:
- To fit your personal needs.
- For security. Say if https://emgithub.com/ is hacked...
- For stability. There may be some breaking changes with https://emgithub.com/ (although I'm trying to avoid this, e.g., when there are major changes,
embed-v2.js,embed-v3.js... are used. In this way, the former embeddings are not affected).
To do this, you can use either GitHub Pages or your own web server.
Use GitHub Pages
If you choose to use GitHub Pages just like https://emgithub.com/ does, you can fork the project and remove the CNAME file. Then go to Your repository - Settings - GitHub Pages to setup a custom domain or simply use username.github.io.
Use your own web server
If you choose to use your own web server, such as Apache and Nginx, the most important thing to do is to configure the server to serve 404.html for a not-found request.
For example, here is a simple configuration without HTTPS for Nginx:
server {
listen 80;
listen [::]:80;
server_name your_domain.com;
root /var/www/project_directory;
location / {
try_files $uri /404.html;
}
}
Credits
- Highlight.js - Javascript syntax highlighter.
- highlightjs-line-numbers.js - Highlight.js line numbers plugin.
- marked - Markdown parser.
- github-markdown-css - GitHub Markdown style.
- notebookjs - Jupyter/IPython notebooks render.
- Loading.io - Loading animation.
- GitHub Corners.
- Icons made by Vectors Market and Dave Gandy from www.flaticon.com.
Related Skills
node-connect
341.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
341.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.4kCommit, push, and open a PR
