#gitlab #url #code-block #github #markdown #git #turn

git2codeblock

Turn GitHub and GitLab codesnippet URLs into Markdown codeblocks

1 unstable release

0.1.0 Aug 25, 2021

#6 in #code-block

GPL-3.0 license

17KB
168 lines

git2codeblock

Crates.io Docs.rs Build Clippy Audit

git2codeblock is a crate that converts git URLs into codeblocks. This is mainly for use in one of my Discord bots, but is written to be used anywhere.

Example

Given the url: https://gitlab.com/ewpratten/DeepSpace/-/blob/master/CODEOWNERS#L2, git2codeblock will realize that this is GitLab, correctly process the file, and return a Markdown fenced codeblock.

let url = "https://gitlab.com/ewpratten/DeepSpace/-/blob/master/CODEOWNERS#L2";
let codeblock = git2codeblock::extract_codeblock(url).await.unwrap();
assert_eq!(codeblock, "```\n*       @ewpratten @slownie @johnlownie @LordMichaelmort @awpratten\n```");

Dependencies

~5–22MB
~291K SLoC