January 30, 2023

How do I embed a single file from a GitHub gist that include multiple files?

I had to look again for it so let me document it here. How do I embed a single file from a GitHub gist that include multiple files?

Question: How do I embed a single file from a GitHub gist that include multiple files?

Answer

Append to the url ?file=filename_with_ext 

Example:

<script src="https://gist.github.com/tdalon/8d396639c43bc2100224df00a5f84c7d.js?file=Outlook_Item2Emails.ahk"></script>

will render:


Outlook_Item2Emails(oItem:="",sMode :="",validate:=False) {
; sEmailList := Outlook_Item2Emails(oItem:="",sMode:="",validate:= False)
; If oItem is empty, GetCurrentItem
; If sMode is empty, user will be prompted for selection noFrom|noTo|noCc
; sMode string containing noFrom, noTo, noCc
; validate: if True user will have the possibility to edit the email List in an InputBox
olApp := ComObjActive("Outlook.Application")
If (oItem == "")
oItem := Outlook_GetCurrentItem(olApp)
If (sMode == "") { ; Prompt user for selection
sMode := ListView("To Chat","Select Fields to exclude","noCc|noFrom|noTo","Fields",False)
If (sMode == "ListViewCancel")
return
}
; Loop on Recipients
cnt := oItem.Recipients.Count
Loop, %cnt%
{
oRecip := oItem.Recipients.Item(A_Index)
; https://learn.microsoft.com/en-us/office/vba/api/outlook.olmailrecipienttype
If ((oRecip.Type == 1) and !InStr(sMode,"noTo"))
or ((oRecip.Type == 2) and !InStr(sMode,"noCc"))
or ((oRecip.Type == 0) and !InStr(sMode,"noFrom"))
{
sEmail := Outlook_Recipient2Email(oRecip)
sEmailList := sEmailList . ";" . sEmail
}
}
RegExReplace(sEmailList, ";" , , nCount)
sEmailList := SubStr(sEmailList,2) ; remove starting ;
If (validate) {
sEMailList:=MultiLineInputBox("Edit Email List (" . nCount . "):", sEmailList, "To Chat")
if (ErrorLevel)
return
}
return sEmailList
} ; eofun

The gist include multiple files.