Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ewpratten/git2codeblock
Turn GitHub and GitLab codesnippet URLs into Markdown codeblocks
https://github.com/ewpratten/git2codeblock
code-fetch codeblock git-codeblock markdown utility
Last synced: 8 days ago
JSON representation
Turn GitHub and GitLab codesnippet URLs into Markdown codeblocks
- Host: GitHub
- URL: https://github.com/ewpratten/git2codeblock
- Owner: ewpratten
- License: gpl-3.0
- Created: 2021-08-25T12:45:12.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2021-08-25T14:08:49.000Z (about 3 years ago)
- Last Synced: 2024-10-09T20:41:33.117Z (29 days ago)
- Topics: code-fetch, codeblock, git-codeblock, markdown, utility
- Language: Rust
- Homepage: https://crates.io/crates/git2codeblock
- Size: 16.6 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# git2codeblock
[![Crates.io](https://img.shields.io/crates/v/git2codeblock)](https://crates.io/crates/git2codeblock)
[![Docs.rs](https://docs.rs/git2codeblock/badge.svg)](https://docs.rs/git2codeblock)
[![Build](https://github.com/Ewpratten/git2codeblock/actions/workflows/build.yml/badge.svg)](https://github.com/Ewpratten/git2codeblock/actions/workflows/build.yml)
[![Clippy](https://github.com/Ewpratten/git2codeblock/actions/workflows/clippy.yml/badge.svg)](https://github.com/Ewpratten/git2codeblock/actions/workflows/clippy.yml)
[![Audit](https://github.com/Ewpratten/git2codeblock/actions/workflows/audit.yml/badge.svg)](https://github.com/Ewpratten/git2codeblock/actions/workflows/audit.yml)`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`](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.
```rust
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```");
```