📦 Update dependencies and enhance functionality for markdown rendering
The changes include updates to dependencies in `Cargo.lock` and `Cargo.toml`, along with enhancements to the markdown rendering script: 1. Added new dependencies: `reqwest` for HTTP requests and `rust_util` for utility functions. 2. Modified `main.rs` to support reading from both local files and URLs, improving flexibility. 3. Updated metadata files (`script-meta-v2.json` and `script-meta.json`) to reflect changes in script size and hash. These updates expand the script's capabilities while ensuring compatibility with existing features.
This commit is contained in:
13
justfile
Normal file
13
justfile
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
_:
|
||||||
|
@just --list
|
||||||
|
|
||||||
|
alias pub:=publish
|
||||||
|
alias p:=publish
|
||||||
|
|
||||||
|
# Publish
|
||||||
|
publish:
|
||||||
|
ls | grep -v update-meta-rs | grep '\-rs$' > file-meta.txt
|
||||||
|
./update-meta-rs/src/main.rs
|
||||||
|
./update-meta-v1.rs
|
||||||
|
commit.ts --auto-commit
|
||||||
|
|
||||||
1724
md-rs/Cargo.lock
generated
1724
md-rs/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -4,4 +4,6 @@ version = "0.1.0"
|
|||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
reqwest = { version = "0.13.2", features = ["blocking"] }
|
||||||
|
rust_util = "0.6.51"
|
||||||
termimad = "0.34.1"
|
termimad = "0.34.1"
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
//! ```cargo
|
//! ```cargo
|
||||||
//! [dependencies]
|
//! [dependencies]
|
||||||
|
//! reqwest = { version = "0.13.2", features = ["blocking"] }
|
||||||
|
//! rust_util = "0.6.51"
|
||||||
//! termimad = "0.34.1"
|
//! termimad = "0.34.1"
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
@@ -12,22 +14,20 @@
|
|||||||
// skin.italic.add_attr(Underlined);
|
// skin.italic.add_attr(Underlined);
|
||||||
// println!("\nand now {}\n", skin.inline("a little *too much* **style!** (and `some(code)` too)"));
|
// println!("\nand now {}\n", skin.inline("a little *too much* **style!** (and `some(code)` too)"));
|
||||||
|
|
||||||
use std::fs;
|
use rust_util::{opt_result, warning, XResult};
|
||||||
|
use std::io::Read;
|
||||||
|
use std::{fs, io};
|
||||||
|
|
||||||
// https://github.com/Canop/termimad
|
// https://github.com/Canop/termimad
|
||||||
fn main() {
|
fn main() {
|
||||||
let args = std::env::args().skip(1).collect::<Vec<_>>();
|
let args = std::env::args().skip(1).collect::<Vec<_>>();
|
||||||
if args.is_empty() {
|
|
||||||
println!("Usage: md.rs <path>");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if args.len() > 1 {
|
if args.len() > 1 {
|
||||||
println!("[ERROR] Only support 1 md file");
|
println!("[ERROR] Only support 1 md URL or file");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
match fs::read_to_string(&args[0]) {
|
let first_arg = args.first();
|
||||||
|
match read_to_string(first_arg) {
|
||||||
Ok(md) => {
|
Ok(md) => {
|
||||||
// termimad::print_inline(&md);
|
|
||||||
termimad::print_text(&md);
|
termimad::print_text(&md);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
@@ -36,5 +36,33 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260411T233243+08:00.MEUCIDN8Gn/U6U95quVMM2wU
|
fn read_to_string(path_opt: Option<&String>) -> XResult<String> {
|
||||||
// XhZj2nIQmDzmtQ3gSjrVT0SdAiEAlFYvzjgxODM2dPiYVUsCcIwgMpNQbDXk9n67b5wq0J8=
|
match path_opt {
|
||||||
|
None => {
|
||||||
|
let mut buffer = String::new();
|
||||||
|
io::stdin().read_to_string(&mut buffer)?;
|
||||||
|
Ok(buffer)
|
||||||
|
}
|
||||||
|
Some(path) => {
|
||||||
|
let is_http_path = path.starts_with("http://");
|
||||||
|
let is_https_path = path.starts_with("https://");
|
||||||
|
if is_http_path || is_https_path {
|
||||||
|
if is_http_path {
|
||||||
|
warning!("Unsecure path: ${path}")
|
||||||
|
}
|
||||||
|
Ok(opt_result!(
|
||||||
|
reqwest::blocking::get(path)?.text(),
|
||||||
|
"Get {path} failed: {}"
|
||||||
|
))
|
||||||
|
} else {
|
||||||
|
Ok(opt_result!(
|
||||||
|
fs::read_to_string(path),
|
||||||
|
"Read {path} failed: {}"
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260412T235541+08:00.MEUCID7zWIZ1zyjpISPbbROS
|
||||||
|
// X+wrb0hfpeWaan8mYIaG9hoaAiEAw1jj2TvjDx0Y6egXTfpIQD5XzW91sutNjSz62Nc9taI=
|
||||||
|
|||||||
@@ -82,11 +82,11 @@
|
|||||||
},
|
},
|
||||||
"md.rs": {
|
"md.rs": {
|
||||||
"script_name": "md.rs",
|
"script_name": "md.rs",
|
||||||
"script_length": 1131,
|
"script_length": 2081,
|
||||||
"script_sha256": "7e58d843fc03cb35eba917a4d1f32be55d4f66e24ef776769d7cd50b6ab3a5ba",
|
"script_sha256": "d4723b7f59bd9e805a4a482e3107f2f30ec70d24d8efb3717b7bc7008a1cc67b",
|
||||||
"script_full_url": "https://git.hatter.ink/rust-scripts/scriptbase/raw/branch/main/md-rs/src/main.rs",
|
"script_full_url": "https://git.hatter.ink/rust-scripts/scriptbase/raw/branch/main/md-rs/src/main.rs",
|
||||||
"publish_time": 1775921621093,
|
"publish_time": 1775921621093,
|
||||||
"update_time": 1775921621093
|
"update_time": 1776009548379
|
||||||
},
|
},
|
||||||
"myip.rs": {
|
"myip.rs": {
|
||||||
"script_name": "myip.rs",
|
"script_name": "myip.rs",
|
||||||
|
|||||||
@@ -46,8 +46,8 @@
|
|||||||
},
|
},
|
||||||
"md-rs": {
|
"md-rs": {
|
||||||
"script_name": "md-rs",
|
"script_name": "md-rs",
|
||||||
"script_length": 1131,
|
"script_length": 2081,
|
||||||
"script_sha256": "7e58d843fc03cb35eba917a4d1f32be55d4f66e24ef776769d7cd50b6ab3a5ba"
|
"script_sha256": "d4723b7f59bd9e805a4a482e3107f2f30ec70d24d8efb3717b7bc7008a1cc67b"
|
||||||
},
|
},
|
||||||
"myip-rs": {
|
"myip-rs": {
|
||||||
"script_name": "myip-rs",
|
"script_name": "myip-rs",
|
||||||
|
|||||||
Reference in New Issue
Block a user