Skip to main content

Module github

Module github 

Source
Expand description

GitHub Permalink expansion.

This module provides functionality for parsing GitHub permalink URLs and fetching raw file content to display as code blocks.

Structsยง

GitHubPermalink
A parsed GitHub permalink.
LineRange
A line range extracted from a GitHub permalink fragment.

Enumsยง

GitHubExpandError
Errors that can occur when expanding a GitHub permalink.

Staticsยง

GITHUB_PERMALINK_REGEX ๐Ÿ”’
Regex pattern for matching GitHub blob URLs.

Functionsยง

is_commit_sha ๐Ÿ”’
Returns true if the given string looks like a commit SHA (4-40 hex characters).
language_for_path ๐Ÿ”’
Extracts the filename from a path and returns the appropriate language identifier.
shorten_ref ๐Ÿ”’
Shortens a git ref for display. Commit SHAs are truncated to 7 characters; branch/tag names are returned as-is.
truncate_lines ๐Ÿ”’
Truncates lines to the given maximum, returning the joined string and whether truncation occurred.