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.

Re-exportsยง

use futures_util::future::join_all; ๐Ÿ”’
use regex::Regex; ๐Ÿ”’
use std::sync::LazyLock; ๐Ÿ”’
use super::ExpandContext; ๐Ÿ”’
use super::ExpandError; ๐Ÿ”’
use super::ExpandedContent; ๐Ÿ”’
use super::LinkExpander; ๐Ÿ”’
use crate::config::BabyriteConfig; ๐Ÿ”’
use crate::utils::escape_markdown; ๐Ÿ”’
use crate::utils::inline_code; ๐Ÿ”’
use crate::utils::language_for_path; ๐Ÿ”’

Structsยง

GitHubExpander
GitHub permalink expander.
GitHubPermalink
A parsed GitHub permalink.
LimitedBody ๐Ÿ”’
Accumulates response chunks until its ReadLimit is met, MAX_BODY_BYTES is exceeded by the retained bytes, or MAX_SKIPPED_BYTES is exceeded by the skipped ones.
LineRange
A line range extracted from a GitHub permalink fragment.
ReadLimit ๐Ÿ”’
The leading part of a body that needs to be read.

Enumsยง

GitHubExpandError
Errors that can occur when expanding a GitHub permalink.

Constantsยง

BOM_SNIFF_BYTES ๐Ÿ”’
Number of leading bytes needed to tell a UTF-16 BOM from anything else.
MAX_BODY_BYTES ๐Ÿ”’
Maximum number of body bytes read from a raw response.
MAX_SKIPPED_BYTES ๐Ÿ”’
Maximum number of bytes discarded before the first displayed line.
PROBE_BYTES ๐Ÿ”’
Number of bytes read past the last needed line to tell whether more follows.

Staticsยง

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

Functionsยง

ensure_not_empty ๐Ÿ”’
Rejects a code block with nothing to show.
is_commit_sha ๐Ÿ”’
Returns true if the given string looks like a commit SHA (4-40 hex characters).
read_body_limited ๐Ÿ”’
Reads the response body chunk by chunk, stopping as soon as limit is met.
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.