Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:CiteGithub: Difference between revisions

From starcup wiki
Created page with "local CiteGithub = {} function CiteGithub.main(frame) local args = frame:getParent().args local argPath = args[1] -- trim off beginning of link local hashStartIndex = argPath:find("https://github.com/teamstarcup/starcup/blob/") local trimmedPath = argPath:sub(hashStartIndex) -- trim off commit hash local filePath = trimmedPath:sub(trimmedPath:find("/")) -- trim off line number range local displayedFilePath = trimmedPath:sub(1, trimmedPath:find("#")) re..."
 
No edit summary
Line 15: Line 15:
local displayedFilePath = trimmedPath:sub(1, trimmedPath:find("#"))
local displayedFilePath = trimmedPath:sub(1, trimmedPath:find("#"))
return string.format("[%s %s]", argPath, displayedFilePath)
return string.format("[%s %s]", argPath, trimmedPath)
end
end


return CiteGithub
return CiteGithub

Revision as of 07:02, 30 May 2025

Documentation for this module may be created at Module:CiteGithub/doc

local CiteGithub = {}

function CiteGithub.main(frame)
	local args = frame:getParent().args
	local argPath = args[1]
	
	-- trim off beginning of link
	local hashStartIndex = argPath:find("https://github.com/teamstarcup/starcup/blob/")
	local trimmedPath = argPath:sub(hashStartIndex)
	
	-- trim off commit hash
	local filePath = trimmedPath:sub(trimmedPath:find("/"))
	
	-- trim off line number range
	local displayedFilePath = trimmedPath:sub(1, trimmedPath:find("#"))
	
	return string.format("[%s %s]", argPath, trimmedPath)
end

return CiteGithub