October 6, 2020

Blogger: Embed GitHub file

I have looked for an answer to this question: How to embed a GitHub file in a Blogger blog post?
For a file in Gist it is pretty direct to get the embed code.
For a file in GitHub I have found this solution http://gist-it.appspot.com/ from this answer in StackOverflow here.

Example for this file: https://github.com/tdalon/ahk/blob/master/Teamsy.ahk

The script part looks like this:
 <script src="http://gist-it.appspot.com/https://github.com/tdalon/ahk/raw/master/Teamsy.ahk"></script>

Since I will have problem to remember it, I have implemented it the IntelliPaste feature of the NWS PowerTool.

The AHK code looks like this:

If InStr(sClipboard,"https://github.com/") {
    sFile := StrReplace(sClipboard,"/blob/","/raw/")
    sFullText = <script src="http://gist-it.appspot.com/%sFile%"></script>
    Clip_Paste(sFullText)
}    
Now copying the Github link and pressing the Ins key will paste the script code part automagically.

No comments:

Post a Comment