file_path
stringlengths
3
280
file_language
stringclasses
66 values
content
stringlengths
1
1.04M
repo_name
stringlengths
5
92
repo_stars
int64
0
154k
repo_description
stringlengths
0
402
repo_primary_language
stringclasses
108 values
developer_username
stringlengths
1
25
developer_name
stringlengths
0
30
developer_company
stringlengths
0
82
src/kbs2/agent.rs
Rust
use std::collections::HashMap; use std::fs; use std::io::{BufRead, BufReader, BufWriter, Read, Write}; use std::os::unix::net::{UnixListener, UnixStream}; use std::path::PathBuf; use std::process::{Command, Stdio}; use std::thread; use std::time::Duration; use age::secrecy::{ExposeSecret as _, SecretString}; use anyho...
woodruffw/kbs2
126
A secret manager backed by age
Rust
woodruffw
William Woodruff
astral-sh
src/kbs2/backend.rs
Rust
use std::fs; use std::io::{Read, Write}; use std::path::Path; use std::str::FromStr; use age::armor::{ArmoredReader, ArmoredWriter, Format}; use age::secrecy::{ExposeSecret as _, SecretString}; use age::Decryptor; use anyhow::{anyhow, Context, Result}; use crate::kbs2::agent; use crate::kbs2::config; use crate::kbs2:...
woodruffw/kbs2
126
A secret manager backed by age
Rust
woodruffw
William Woodruff
astral-sh
src/kbs2/command.rs
Rust
use std::convert::TryInto; use std::env; use std::fmt::Write as _; use std::io::{self, stdin, IsTerminal, Read, Seek, Write}; use std::path::{Path, PathBuf}; use std::process; use age::secrecy::{ExposeSecret as _, SecretBox}; use anyhow::{anyhow, Result}; use arboard::Clipboard; use clap::ArgMatches; use daemonize::Da...
woodruffw/kbs2
126
A secret manager backed by age
Rust
woodruffw
William Woodruff
astral-sh
src/kbs2/config.rs
Rust
use std::collections::HashMap; use std::env; use std::ffi::OsStr; use std::fs; use std::io::{stdin, IsTerminal}; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; use age::secrecy::SecretString; use anyhow::{anyhow, Result}; use clap::ArgMatches; use lazy_static::lazy_static; use serde::{de, Deserial...
woodruffw/kbs2
126
A secret manager backed by age
Rust
woodruffw
William Woodruff
astral-sh
src/kbs2/generator.rs
Rust
use anyhow::{anyhow, Result}; use rand::seq::{IteratorRandom, SliceRandom}; use crate::kbs2::config; /// Represents the operations that all generators are capable of. pub trait Generator { /// Returns the name of the generator, e.g. `"default"`. fn name(&self) -> &str; /// Returns a secret produced by th...
woodruffw/kbs2
126
A secret manager backed by age
Rust
woodruffw
William Woodruff
astral-sh
src/kbs2/input.rs
Rust
use std::io::{self, Read}; use anyhow::{anyhow, Result}; use inquire::{Password as Pass, Text}; use super::record::{EnvironmentFields, LoginFields, RecordBody, UnstructuredFields}; use crate::kbs2::config::RuntimeConfig; use crate::kbs2::generator::Generator; /// The input separator used when input is gathered in "t...
woodruffw/kbs2
126
A secret manager backed by age
Rust
woodruffw
William Woodruff
astral-sh
src/kbs2/mod.rs
Rust
/// Structures and routines for the `kbs2` authentication agent. pub mod agent; /// Structures and routines for interacting with age backends. pub mod backend; /// Routines for the various `kbs2` subcommands. pub mod command; /// Structures and routines for `kbs2`'s configuration. pub mod config; /// Structures and...
woodruffw/kbs2
126
A secret manager backed by age
Rust
woodruffw
William Woodruff
astral-sh
src/kbs2/record.rs
Rust
use age::secrecy::zeroize::Zeroize; use serde::{Deserialize, Serialize}; use crate::kbs2::util; // TODO(ww): Figure out how to generate this from the RecordBody enum below. /// The stringified names of record kinds known to `kbs2`. pub static RECORD_KINDS: &[&str] = &["login", "environment", "unstructured"]; /// Rep...
woodruffw/kbs2
126
A secret manager backed by age
Rust
woodruffw
William Woodruff
astral-sh
src/kbs2/session.rs
Rust
use std::convert::TryFrom; use std::fs; use std::io; use std::path::Path; use anyhow::{anyhow, Result}; use crate::kbs2::agent::Agent; use crate::kbs2::backend::{Backend, RageLib}; use crate::kbs2::config; use crate::kbs2::record; /// Encapsulates the context needed by `kbs2` to interact with records. pub struct Ses...
woodruffw/kbs2
126
A secret manager backed by age
Rust
woodruffw
William Woodruff
astral-sh
src/kbs2/util.rs
Rust
use std::ffi::OsStr; use std::fs::File; use std::io::Read; use std::path::Path; use std::time::{SystemTime, UNIX_EPOCH}; use age::secrecy::SecretString; use anyhow::{anyhow, Result}; use pinentry::PassphraseInput; /// Given an input string formatted according to shell quoting rules, /// split it into its command and ...
woodruffw/kbs2
126
A secret manager backed by age
Rust
woodruffw
William Woodruff
astral-sh
src/main.rs
Rust
//! The entrypoint for the `kbs2` CLI. #![deny(rustdoc::broken_intra_doc_links)] #![deny(missing_docs)] #![deny(clippy::unwrap_used)] #![deny(clippy::expect_used)] #![deny(clippy::panic)] use std::ffi::{OsStr, OsString}; use std::process; use std::{io, path::PathBuf}; use anyhow::{anyhow, Context, Result}; use clap:...
woodruffw/kbs2
126
A secret manager backed by age
Rust
woodruffw
William Woodruff
astral-sh
tests/common/mod.rs
Rust
// NOTE(ww): Dead code allowed because of this `cargo test` bug: // https://github.com/rust-lang/rust/issues/46379 #![allow(dead_code)] use std::process::Output; use assert_cmd::Command; use serde_json::Value; use tempfile::TempDir; #[derive(Debug)] pub struct CliSession { pub config_dir: TempDir, pub store_...
woodruffw/kbs2
126
A secret manager backed by age
Rust
woodruffw
William Woodruff
astral-sh
tests/test_kbs2.rs
Rust
mod common; use clap::ValueEnum; use clap_complete::Shell; use common::kbs2; #[test] fn test_kbs2_help() { // `help`, `--help`, and `-h` all produce the same output let reference_output = kbs2().arg("help").output().unwrap(); assert!(reference_output.status.success()); for help in &["--help", "-h"] ...
woodruffw/kbs2
126
A secret manager backed by age
Rust
woodruffw
William Woodruff
astral-sh
tests/test_kbs2_init.rs
Rust
mod common; use common::CliSession; #[test] fn test_kbs2_init() { let session = CliSession::new(); let config_dir = session.config_dir.path(); let store_dir = session.store_dir.path(); // Our config dir, etc. all exist; the store dir is empty. assert!(config_dir.is_dir()); assert!(store_dir....
woodruffw/kbs2
126
A secret manager backed by age
Rust
woodruffw
William Woodruff
astral-sh
tests/test_kbs2_new.rs
Rust
mod common; use common::{CliSession, ToJson}; use serde_json::json; // TODO: Figure out how to test prompts instead of terse inputs. #[test] fn test_kbs2_new_login() { let session = CliSession::new(); session .command() .args(["new", "-k", "login", "test-record"]) .write_stdin("fakeu...
woodruffw/kbs2
126
A secret manager backed by age
Rust
woodruffw
William Woodruff
astral-sh
tests/test_kbs2_rename.rs
Rust
mod common; use common::CliSession; #[test] fn test_kbs2_rename() { let session = CliSession::new(); // `rename` deletes the old record. session .command() .args(["new", "-k", "login", "test-record"]) .write_stdin("fakeuser\x01fakepass") .assert() .success(); ...
woodruffw/kbs2
126
A secret manager backed by age
Rust
woodruffw
William Woodruff
astral-sh
tests/test_kbs2_rm.rs
Rust
mod common; use common::CliSession; #[test] fn test_kbs2_rm() { let session = CliSession::new(); // `kbs2 rm` with a nonexistent record fails. { session .command() .args(["rm", "does-not-exist"]) .assert() .failure(); } // `kbs2 rm` works a...
woodruffw/kbs2
126
A secret manager backed by age
Rust
woodruffw
William Woodruff
astral-sh
src/lib.rs
Rust
use std::path::Path; use libc::pid_t; use pyo3::exceptions::{PyException, PyIOError}; use pyo3::prelude::*; use pyo3::{create_exception, wrap_pyfunction}; use rsprocmaps::error::Error; create_exception!(procmaps, ParseError, PyException); /// Represents a memory map in the maps file. #[pyclass] struct Map { inne...
woodruffw/procmaps.py
35
Python bindings for procmaps.rs
Rust
woodruffw
William Woodruff
astral-sh
test/test_procmaps.py
Python
import os import unittest import procmaps class TestProcmaps(unittest.TestCase): def check_map_properties(self, map_): self.assertIsInstance(map_.begin_address, int) self.assertIsInstance(map_.end_address, int) self.assertTrue(map_.begin_address in map_) self.assertFalse(map_.end...
woodruffw/procmaps.py
35
Python bindings for procmaps.rs
Rust
woodruffw
William Woodruff
astral-sh
src/error.rs
Rust
//! Error types for `rsprocmaps`. use std::error; use std::fmt; use std::io; use std::num; use pest::error::Error as PestError; use crate::Rule; /// An enumeration of possible error states for `rsprocmaps`. #[derive(Debug)] pub enum Error { /// An I/O error. Io(io::Error), // NOTE(ww): PestError<Rule> i...
woodruffw/procmaps.rs
15
A small Rust library for reading process maps from procfs
Rust
woodruffw
William Woodruff
astral-sh
src/lib.rs
Rust
//! A small Rust library for parsing `/proc/<pid>/maps`. #![deny(rustdoc::broken_intra_doc_links)] #![allow(clippy::redundant_field_names)] #![forbid(unsafe_code)] use std::fmt; use std::fs::File; use std::io::Lines; use std::io::{BufRead, BufReader}; use std::path::Path; use libc::pid_t; use pest::Parser as ParserT...
woodruffw/procmaps.rs
15
A small Rust library for reading process maps from procfs
Rust
woodruffw
William Woodruff
astral-sh
pyrage-stubs/pyrage/__init__.pyi
Python
from io import BufferedIOBase from typing import Sequence, Union from pyrage import passphrase, plugin, ssh, x25519 from pyrage.plugin import IdentityPluginV1, RecipientPluginV1 from pyrage.ssh import Identity as SSHIdentity from pyrage.ssh import Recipient as SSHRecipient from pyrage.x25519 import Identity as X25519I...
woodruffw/pyrage
80
Python bindings for rage (age in Rust)
Rust
woodruffw
William Woodruff
astral-sh
pyrage-stubs/pyrage/passphrase.pyi
Python
def encrypt(plaintext: bytes, passphrase: str, armored: bool = False) -> bytes: ... def decrypt(ciphertext: bytes, passphrase: str, armored: bool = False) -> bytes: ...
woodruffw/pyrage
80
Python bindings for rage (age in Rust)
Rust
woodruffw
William Woodruff
astral-sh
pyrage-stubs/pyrage/plugin.pyi
Python
from __future__ import annotations from typing import Sequence, Self, Optional, Protocol class Callbacks(Protocol): def display_message(self, message: str) -> None: ... def confirm(self, message: str, yes_string: str, no_string: Optional[str]) -> Optional[bool]: ... def request_public_st...
woodruffw/pyrage
80
Python bindings for rage (age in Rust)
Rust
woodruffw
William Woodruff
astral-sh
pyrage-stubs/pyrage/ssh.pyi
Python
from __future__ import annotations class Identity: @classmethod def from_buffer(cls, buf: bytes) -> Identity: ... class Recipient: @classmethod def from_str(cls, v: str) -> Recipient: ...
woodruffw/pyrage
80
Python bindings for rage (age in Rust)
Rust
woodruffw
William Woodruff
astral-sh
pyrage-stubs/pyrage/x25519.pyi
Python
from __future__ import annotations class Identity: @classmethod def generate(cls) -> Identity: ... @classmethod def from_str(cls, v: str) -> Identity: ... def to_public(self) -> Recipient: ... class Recipient: @classmethod def from_str(cls, v: str) -> Recipient:...
woodruffw/pyrage
80
Python bindings for rage (age in Rust)
Rust
woodruffw
William Woodruff
astral-sh
pyrage-stubs/setup.py
Python
from setuptools import setup # editable installs don't work with pyproject.toml + setuptools yet, # so we need this stub. setup()
woodruffw/pyrage
80
Python bindings for rage (age in Rust)
Rust
woodruffw
William Woodruff
astral-sh
src/lib.rs
Rust
#![deny(unsafe_code)] use std::collections::HashSet; use std::io::Write; use std::{fs::File, io::Read}; use age::{ armor::ArmoredReader, armor::ArmoredWriter, armor::Format, DecryptError as RageDecryptError, EncryptError as RageEncryptError, Encryptor, Identity, Recipient, }; use age_core::format::{FileKey, S...
woodruffw/pyrage
80
Python bindings for rage (age in Rust)
Rust
woodruffw
William Woodruff
astral-sh
src/passphrase.rs
Rust
use std::{ io::{Read, Write}, iter, }; use age::{ armor::ArmoredReader, armor::ArmoredWriter, armor::Format, scrypt, Decryptor, Encryptor, }; use pyo3::{prelude::*, types::PyBytes}; use crate::{DecryptError, EncryptError}; #[pyfunction] #[pyo3(signature = (plaintext, passphrase, armored=false))] fn encry...
woodruffw/pyrage
80
Python bindings for rage (age in Rust)
Rust
woodruffw
William Woodruff
astral-sh
src/plugin.rs
Rust
use std::str::FromStr; use std::sync::Arc; use pyo3::{prelude::*, types::PyType}; use crate::{DecryptError, EncryptError, IdentityError, RecipientError}; /// Hack, because the orphan rule would prevent us from deriving a /// foreign trait on a foreign object. Instead, define a newtype. /// /// Inner type is PyAny, b...
woodruffw/pyrage
80
Python bindings for rage (age in Rust)
Rust
woodruffw
William Woodruff
astral-sh
src/ssh.rs
Rust
use std::str::FromStr; use pyo3::{prelude::*, types::PyType}; use crate::{IdentityError, RecipientError}; #[pyclass(module = "pyrage.ssh")] #[derive(Clone)] pub(crate) struct Recipient(pub(crate) age::ssh::Recipient); #[pymethods] impl Recipient { #[classmethod] fn from_str(_cls: &Bound<'_, PyType>, v: &str...
woodruffw/pyrage
80
Python bindings for rage (age in Rust)
Rust
woodruffw
William Woodruff
astral-sh
src/x25519.rs
Rust
use std::str::FromStr; use age::secrecy::ExposeSecret; use pyo3::{prelude::*, types::PyType}; use crate::{IdentityError, RecipientError}; #[pyclass(module = "pyrage.x25519")] #[derive(Clone)] pub(crate) struct Recipient(pub(crate) age::x25519::Recipient); #[pymethods] impl Recipient { #[classmethod] fn from...
woodruffw/pyrage
80
Python bindings for rage (age in Rust)
Rust
woodruffw
William Woodruff
astral-sh
test/test_passphrase.py
Python
import unittest from parameterized import parameterized from pyrage import passphrase class TestPassphrase(unittest.TestCase): @parameterized.expand([(False,), (True,)]) def test_roundtrip(self, armored): plaintext = b"junk" encrypted = passphrase.encrypt(plaintext, "some password", armored=...
woodruffw/pyrage
80
Python bindings for rage (age in Rust)
Rust
woodruffw
William Woodruff
astral-sh
test/test_pyrage.py
Python
import os import tempfile import unittest from io import BytesIO from parameterized import parameterized import pyrage from .utils import ssh_keypair class TestPyrage(unittest.TestCase): def test_encrypt_fails_with_no_receipients(self): with self.assertRaisesRegex( pyrage.EncryptError, "exp...
woodruffw/pyrage
80
Python bindings for rage (age in Rust)
Rust
woodruffw
William Woodruff
astral-sh
test/test_ssh.py
Python
import unittest from pyrage import RecipientError, ssh from .utils import ssh_keypair class TestIdentity(unittest.TestCase): def test_from_buffer(self): for filename in ["ed25519", "rsa4096", "rsa2048"]: _pubkey, privkey = ssh_keypair(filename) identity = ssh.Identity.from_buffer...
woodruffw/pyrage
80
Python bindings for rage (age in Rust)
Rust
woodruffw
William Woodruff
astral-sh
test/test_x25519.py
Python
import unittest from pyrage import x25519, IdentityError, RecipientError class TestIdentity(unittest.TestCase): def test_generate(self): identity = x25519.Identity.generate() self.assertIsInstance(identity, x25519.Identity) self.assertTrue(str(identity).startswith("AGE-SECRET-KEY")) ...
woodruffw/pyrage
80
Python bindings for rage (age in Rust)
Rust
woodruffw
William Woodruff
astral-sh
test/utils.py
Python
from pathlib import Path _HERE = Path(__file__).parent _ASSETS = _HERE / "assets" assert _ASSETS.is_dir(), "missing test assets directory" def ssh_keypair(name): (pub, priv) = (_ASSETS / f"{name}.pub", _ASSETS / name) return (pub.read_text(), priv.read_text())
woodruffw/pyrage
80
Python bindings for rage (age in Rust)
Rust
woodruffw
William Woodruff
astral-sh
shaq/__init__.py
Python
__version__ = "0.0.5"
woodruffw/shaq
116
A CLI client for Shazam
Python
woodruffw
William Woodruff
astral-sh
shaq/__main__.py
Python
if __name__ == "__main__": from shaq._cli import main main()
woodruffw/shaq
116
A CLI client for Shazam
Python
woodruffw
William Woodruff
astral-sh
shaq/_cli.py
Python
import argparse import asyncio import json import logging import os import shutil import sys import wave from collections.abc import Iterator from contextlib import contextmanager from io import BytesIO from pathlib import Path from typing import Any import pyaudio from pydub import AudioSegment from rich import progr...
woodruffw/shaq
116
A CLI client for Shazam
Python
woodruffw
William Woodruff
astral-sh
assets/static/index.js
JavaScript
const sortListAlpha = list => [...list].sort((a, b) => { const A = a.textContent.trim(), B = b.textContent.trim(); return (A < B) ? -1 : (A > B) ? 1 : 0; }); const sortListTopicCount = list => [...list].sort((a, b) => { const A = parseInt(a.querySelector(".til-tag-count").textContent, 10); const B = pa...
woodruffw/tiller
11
Tiller Tills TILs
Rust
woodruffw
William Woodruff
astral-sh
assets/static/style.css
CSS
body { font-family: "Helvetica", sans-serif; hyphens: auto; margin: auto; padding: 1em; max-width: 50em; background-color: #F6F6F6; } h1.til-title { margin-bottom: 0px; text-wrap: balance; } pre { border: 1px solid black; padding: 15px; font-size: 14px; overflow: scroll...
woodruffw/tiller
11
Tiller Tills TILs
Rust
woodruffw
William Woodruff
astral-sh
src/config.rs
Rust
use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize)] pub(crate) struct Config { pub(crate) base_url: String, pub(crate) mastodon: Option<String>, #[serde(default)] pub(crate) top_links: Vec<Link>, } #[derive(Serialize, Deserialize)] pub(crate) struct Link { title: String, url...
woodruffw/tiller
11
Tiller Tills TILs
Rust
woodruffw
William Woodruff
astral-sh
src/main.rs
Rust
use std::{fs, path::PathBuf}; use anyhow::{anyhow, Context, Result}; use clap::Parser; use config::Config; mod config; mod render; mod tiller; /// Yet another TIL tracker. #[derive(Parser, Debug)] #[command(version, about, long_about = None)] struct Args { /// The directory to render from. Must contain a `tils` ...
woodruffw/tiller
11
Tiller Tills TILs
Rust
woodruffw
William Woodruff
astral-sh
src/render.rs
Rust
use std::{collections::BTreeMap, path::PathBuf}; use anyhow::{Context, Result}; use comrak::{markdown_to_html, Options}; use handlebars::{handlebars_helper, Handlebars}; use rss::{CategoryBuilder, ChannelBuilder, ItemBuilder}; use rust_embed::Embed; use serde::Serialize; use syntect::highlighting::ThemeSet; use crate...
woodruffw/tiller
11
Tiller Tills TILs
Rust
woodruffw
William Woodruff
astral-sh
src/tiller.rs
Rust
use std::{ collections::{BTreeMap, BTreeSet}, path::Path, }; use anyhow::{anyhow, Result}; use comrak::{ markdown_to_html_with_plugins, options, plugins::syntect::{SyntectAdapter, SyntectAdapterBuilder}, Options, }; use gray_matter::{engine::YAML, Matter}; use serde::{Deserialize, Serialize}; /// ...
woodruffw/tiller
11
Tiller Tills TILs
Rust
woodruffw
William Woodruff
astral-sh
src/main.rs
Rust
#![forbid(unsafe_code)] use std::fs; use std::io::{self, Read}; use anyhow::{Context, Result}; use clap::Parser; /// Convert TOML to JSON #[derive(Parser)] #[command(name = env!("CARGO_PKG_NAME"))] #[command(version = env!("CARGO_PKG_VERSION"))] #[command(about = env!("CARGO_PKG_DESCRIPTION"))] struct Args { ///...
woodruffw/toml2json
92
A very small CLI for converting TOML to JSON
Rust
woodruffw
William Woodruff
astral-sh
build.rs
Rust
use std::env; use std::fs; use std::io::{BufRead, BufReader, BufWriter, Write}; use std::path::Path; use phf_codegen::Map; use quote::quote; /* This build script contains a "parser" for the USB ID database. * "Parser" is in scare-quotes because it's really a line matcher with a small amount * of context needed for ...
woodruffw/usb-ids.rs
25
Cross-platform Rust wrappers for the USB ID Repository
Rust
woodruffw
William Woodruff
astral-sh
src/lib.rs
Rust
//! //! Rust wrappers for the [USB ID Repository](http://www.linux-usb.org/usb-ids.html). //! //! The USB ID Repository is the canonical source of USB device information for most //! Linux userspaces; this crate vendors the USB ID database to allow non-Linux hosts to //! access the same canonical information. //! //! #...
woodruffw/usb-ids.rs
25
Cross-platform Rust wrappers for the USB ID Repository
Rust
woodruffw
William Woodruff
astral-sh
index.d.ts
TypeScript
import type {VFileMessage} from 'vfile-message' export {deadOrAlive, defaultAnchorAllowlist, defaultSleep} from './lib/index.js' /** * Allow extra anchors. * The first item is a regular expression to match URLs (origin and path, * so without search or hash), * and the second item is a regular expression to match ...
wooorm/dead-or-alive
50
check if urls are dead or alive
JavaScript
wooorm
Titus
index.js
JavaScript
// Note: types exposed from `index.d.ts`. export {deadOrAlive, defaultAnchorAllowlist, defaultSleep} from './lib/index.js'
wooorm/dead-or-alive
50
check if urls are dead or alive
JavaScript
wooorm
Titus
lib/anchors.js
JavaScript
/** * @import {Element, Root} from 'hast' */ /** * @typedef Anchor * @property {Element} [systemId] * @property {Element} [systemName] * @property {Element} [userId] * @property {Element} [userName] * * @typedef Options * @property {boolean} resolveClobberPrefix * Accept `user-content-` prefix on elements...
wooorm/dead-or-alive
50
check if urls are dead or alive
JavaScript
wooorm
Titus
lib/fetch.default.js
JavaScript
const fetch_ = fetch export {fetch_ as fetch}
wooorm/dead-or-alive
50
check if urls are dead or alive
JavaScript
wooorm
Titus
lib/fetch.node.js
JavaScript
// Note: we use `undici` as it supports mocking. export {fetch} from 'undici'
wooorm/dead-or-alive
50
check if urls are dead or alive
JavaScript
wooorm
Titus
lib/index.js
JavaScript
/** * @import {AnchorAllow, Options, Result, Sleep} from 'dead-or-alive' * @import {Root} from 'hast' */ /** * @typedef State * State. * @property {ReadonlyArray<Readonly<AnchorAllow>>} anchorAllowlist * Allow anchors. * @property {boolean} checkAnchor * Check whether URL hashes point to elements. * @p...
wooorm/dead-or-alive
50
check if urls are dead or alive
JavaScript
wooorm
Titus
lib/propose.js
JavaScript
/** * @typedef {[value: string, score: number]} ValueScoreTuple */ import {levenshteinEditDistance} from 'levenshtein-edit-distance' const relativeThreshold = 0.5 const max = 4 /** * @param {string} value * @param {ReadonlyArray<string>} ideas * @returns {Array<string>} */ export function propose(value, ideas)...
wooorm/dead-or-alive
50
check if urls are dead or alive
JavaScript
wooorm
Titus
lib/shared-declarative-refresh.js
JavaScript
import {VFileMessage} from 'vfile-message' /** * Implementation of <https://html.spec.whatwg.org/multipage/semantics.html#shared-declarative-refresh-steps>. * * @param {string} input * @param {Readonly<URL>} from * @returns {URL | undefined} */ export function sharedDeclarativeRefresh(input, from) { // 2. le...
wooorm/dead-or-alive
50
check if urls are dead or alive
JavaScript
wooorm
Titus
test.js
JavaScript
/** * @import {VFileMessage} from 'vfile-message' */ import assert from 'node:assert/strict' import test from 'node:test' import {deadOrAlive} from 'dead-or-alive' import {MockAgent, getGlobalDispatcher, setGlobalDispatcher} from 'undici' import {sharedDeclarativeRefresh} from './lib/shared-declarative-refresh.js' i...
wooorm/dead-or-alive
50
check if urls are dead or alive
JavaScript
wooorm
Titus
benches/bench.rs
Rust
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use std::fs; fn readme(c: &mut Criterion) { let doc = fs::read_to_string("readme.md").unwrap(); c.bench_with_input(BenchmarkId::new("readme", "readme"), &doc, |b, s| { b.iter(|| markdown::to_html(s)); }); } // fn one_and_a_...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
examples/lib.rs
Rust
fn main() -> Result<(), markdown::message::Message> { // Turn on debugging. // You can show it with `RUST_LOG=debug cargo run --features log --example lib` env_logger::init(); // Safely turn (untrusted?) markdown into HTML. println!("{:?}", markdown::to_html("## Hello, *world*!")); // Turn tru...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
fuzz/fuzz_targets/markdown_honggfuzz.rs
Rust
use honggfuzz::fuzz; fn main() { loop { fuzz!(|data: &[u8]| { if let Ok(s) = std::str::from_utf8(data) { let _ = markdown::to_html(s); let _ = markdown::to_html_with_options(s, &markdown::Options::gfm()); let _ = markdown::to_mdast(s, &markdown::P...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
fuzz/fuzz_targets/markdown_libfuzz.rs
Rust
#![no_main] use libfuzzer_sys::fuzz_target; fuzz_target!(|data: &[u8]| { if let Ok(s) = std::str::from_utf8(data) { let _ = markdown::to_html(s); let _ = markdown::to_html_with_options(s, &markdown::Options::gfm()); let _ = markdown::to_mdast(s, &markdown::ParseOptions::default()); ...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
generate/src/main.rs
Rust
// To regenerate, run the following from the repository root: // // ```sh // cargo run --manifest-path generate/Cargo.toml // ``` use regex::Regex; use std::fs; #[tokio::main] async fn main() { commonmark().await; punctuation().await; } async fn commonmark() { let url = "https://raw.githubusercontent.com...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/association.rs
Rust
//! Traits for <https://github.com/syntax-tree/mdast#association>. //! //! JS equivalent: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/70e1a4f/types/mdast/index.d.ts#L48. use alloc::string::String; use markdown::mdast::{Definition, ImageReference, LinkReference}; pub trait Association { fn identifier(&...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/configure.rs
Rust
//! Configuration. //! //! JS equivalent: https://github.com/syntax-tree/mdast-util-to-markdown/blob/fd6a508/lib/types.js#L307. #[derive(Clone, Copy)] /// Configuration for indent of lists. pub enum IndentOptions { /// Depends on the item and its parent list: uses `IndentOptions::One` if /// the item and list ...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/construct_name.rs
Rust
//! Names of the things being serialized. //! //! JS equivalent: https://github.com/syntax-tree/mdast-util-to-markdown/blob/fd6a508/index.d.ts#L18. #[derive(Clone, PartialEq)] pub enum ConstructName { /// Whole autolink. /// /// ```markdown /// > | <https://example.com> and <admin@example.com> /// ...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/handle/blockquote.rs
Rust
//! JS equivalent: https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/handle/blockquote.js use super::Handle; use crate::{ construct_name::ConstructName, state::{Info, State}, }; use alloc::string::String; use markdown::{ mdast::{Blockquote, Node}, message::Message, }; impl Handle for...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/handle/break.rs
Rust
//! JS equivalent: https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/handle/break.js use super::Handle; use crate::{ state::{Info, State}, util::pattern_in_scope::pattern_in_scope, }; use alloc::string::ToString; use markdown::{ mdast::{Break, Node}, message::Message, }; impl Handle ...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/handle/code.rs
Rust
//! JS equivalent: https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/handle/code.js use super::Handle; use crate::{ construct_name::ConstructName, state::{Info, State}, util::{ check_fence::check_fence, format_code_as_indented::format_code_as_indented, longest_char_streak:...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/handle/definition.rs
Rust
//! JS equivalent: https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/handle/definition.js use super::Handle; use crate::{ construct_name::ConstructName, state::{Info, State}, util::{ check_quote::check_quote, contains_control_or_whitespace::contains_control_or_whitespace, ...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/handle/emphasis.rs
Rust
//! JS equivalent: https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/handle/emphasis.js use super::Handle; use crate::{ construct_name::ConstructName, state::{Info, State}, util::check_emphasis::check_emphasis, }; use alloc::format; use markdown::{ mdast::{Emphasis, Node}, message...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/handle/heading.rs
Rust
//! JS equivalent: https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/handle/heading.js use super::Handle; use crate::{ construct_name::ConstructName, state::{Info, State}, util::format_heading_as_setext::format_heading_as_setext, }; use alloc::format; use markdown::{ mdast::{Heading, ...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/handle/html.rs
Rust
//! JS equivalent: https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/handle/html.js use super::Handle; use crate::state::{Info, State}; use markdown::{ mdast::{Html, Node}, message::Message, }; impl Handle for Html { fn handle( &self, _state: &mut State, _info: &I...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/handle/image.rs
Rust
//! JS equivalent: https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/handle/image.js use super::Handle; use crate::{ construct_name::ConstructName, state::{Info, State}, util::{ check_quote::check_quote, contains_control_or_whitespace::contains_control_or_whitespace, safe:...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/handle/image_reference.rs
Rust
//! JS equivalent: https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/handle/image-reference.js use super::Handle; use crate::{ construct_name::ConstructName, state::{Info, State}, util::safe::SafeConfig, }; use alloc::string::String; use core::mem; use markdown::{ mdast::{ImageReferen...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/handle/inline_code.rs
Rust
//! JS equivalent: https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/handle/inline-code.js use super::Handle; use crate::state::{Info, State}; use alloc::{format, string::String}; use markdown::{ mdast::{InlineCode, Node}, message::Message, }; use regex::Regex; impl Handle for InlineCode { ...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/handle/inline_math.rs
Rust
//! JS equivalent: https://github.com/syntax-tree/mdast-util-math/blob/main/lib/index.js#L241 use super::Handle; use crate::state::{Info, State}; use alloc::format; use markdown::{ mdast::{InlineMath, Node}, message::Message, }; use regex::Regex; impl Handle for InlineMath { fn handle( &self, ...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/handle/link.rs
Rust
//! JS equivalent: https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/handle/link.js use super::Handle; use crate::{ construct_name::ConstructName, state::{Info, State}, util::{ check_quote::check_quote, contains_control_or_whitespace::contains_control_or_whitespace, format...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/handle/link_reference.rs
Rust
//! JS equivalent: https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/handle/link-reference.js use super::Handle; use crate::{ construct_name::ConstructName, state::{Info, State}, util::safe::SafeConfig, }; use alloc::string::String; use core::mem; use markdown::{ mdast::{LinkReference...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/handle/list.rs
Rust
//! JS equivalent: https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/handle/list.js use super::Handle; use crate::{ construct_name::ConstructName, state::{Info, State}, util::{ check_bullet::check_bullet, check_bullet_ordered::check_bullet_ordered, check_bullet_other::chec...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/handle/list_item.rs
Rust
//! JS equivalent: https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/handle/list-item.js use super::Handle; use crate::{ configure::IndentOptions, construct_name::ConstructName, state::{Info, State}, util::check_bullet::check_bullet, }; use alloc::{ format, string::{String, To...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/handle/math.rs
Rust
//! JS equivalent: https://github.com/syntax-tree/mdast-util-math/blob/main/lib/index.js#L204 use super::Handle; use crate::{ construct_name::ConstructName, state::{Info, State}, util::{longest_char_streak::longest_char_streak, safe::SafeConfig}, }; use alloc::string::String; use markdown::{ mdast::{Ma...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/handle/mod.rs
Rust
use crate::{state::Info, State}; use alloc::string::String; use markdown::{mdast::Node, message::Message}; mod blockquote; mod r#break; mod code; mod definition; pub mod emphasis; mod heading; pub mod html; pub mod image; pub mod image_reference; pub mod inline_code; pub mod inline_math; pub mod link; pub mod link_ref...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/handle/paragraph.rs
Rust
//! JS equivalent: https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/handle/paragraph.js use super::Handle; use crate::{ construct_name::ConstructName, state::{Info, State}, }; use markdown::{ mdast::{Node, Paragraph}, message::Message, }; impl Handle for Paragraph { fn handle( ...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/handle/root.rs
Rust
//! JS equivalent: https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/handle/root.js use super::Handle; use crate::state::{Info, State}; use alloc::string::String; use markdown::{ mdast::{Node, Root}, message::Message, }; impl Handle for Root { fn handle( &self, state: &mu...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/handle/strong.rs
Rust
//! JS equivalent: https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/handle/strong.js use super::Handle; use crate::{ construct_name::ConstructName, state::{Info, State}, util::check_strong::check_strong, }; use alloc::format; use markdown::{ mdast::{Node, Strong}, message::Messag...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/handle/text.rs
Rust
//! JS equivalent: https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/handle/text.js use super::Handle; use crate::{ state::{Info, State}, util::safe::SafeConfig, }; use markdown::{ mdast::{Node, Text}, message::Message, }; impl Handle for Text { fn handle( &self, ...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/handle/thematic_break.rs
Rust
//! JS equivalent: https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/handle/thematic-break.js use super::Handle; use crate::{ state::{Info, State}, util::{check_rule::check_rule, check_rule_repetition::check_rule_repetition}, }; use alloc::format; use markdown::{ mdast::{Node, ThematicBre...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/lib.rs
Rust
//! API. //! //! JS equivalent: https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/index.js. #![no_std] use alloc::string::String; pub use configure::{IndentOptions, Options}; use markdown::{mdast::Node, message::Message}; use state::{Info, State}; extern crate alloc; mod association; mod configure;...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/state.rs
Rust
//! State. //! //! JS equivalent: https://github.com/syntax-tree/mdast-util-to-markdown/blob/fd6a508/lib/types.js#L195. use crate::{ association::Association, construct_name::ConstructName, handle::{ emphasis::peek_emphasis, html::peek_html, image::peek_image, image_reference::peek_image_re...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/unsafe.rs
Rust
//! Unsafe patterns. //! //! JS equivalent: <https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/unsafe.js>. //! Also: <https://github.com/syntax-tree/mdast-util-to-markdown/blob/fd6a508/lib/types.js#L287-L305>. use crate::{construct_name::ConstructName, Options}; use alloc::{vec, vec::Vec}; use regex:...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/util/check_bullet.rs
Rust
//! JS equivalent https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/util/check-bullet.js use crate::state::State; use alloc::{boxed::Box, format}; use markdown::message::Message; pub fn check_bullet(state: &mut State) -> Result<char, Message> { let marker = state.options.bullet; if marker !...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/util/check_bullet_ordered.rs
Rust
//! JS equivalent https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/util/check-bullet-ordered.js use crate::state::State; use alloc::{boxed::Box, format}; use markdown::message::Message; pub fn check_bullet_ordered(state: &mut State) -> Result<char, Message> { let marker = state.options.bullet_o...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/util/check_bullet_other.rs
Rust
//! JS equivalent https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/util/check-bullet-other.js use super::check_bullet::check_bullet; use crate::state::State; use alloc::{boxed::Box, format}; use markdown::message::Message; pub fn check_bullet_other(state: &mut State) -> Result<char, Message> { ...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/util/check_emphasis.rs
Rust
//! JS equivalent https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/util/check-emphasis.js use crate::state::State; use alloc::{boxed::Box, format}; use markdown::message::Message; pub fn check_emphasis(state: &State) -> Result<char, Message> { let marker = state.options.emphasis; if marker...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/util/check_fence.rs
Rust
//! JS equivalent https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/util/check-fence.js use crate::state::State; use alloc::{boxed::Box, format}; use markdown::message::Message; pub fn check_fence(state: &mut State) -> Result<char, Message> { let marker = state.options.fence; if marker != '...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/util/check_quote.rs
Rust
//! JS equivalent https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/util/check-quote.js use crate::state::State; use alloc::{boxed::Box, format}; use markdown::message::Message; pub fn check_quote(state: &State) -> Result<char, Message> { let marker = state.options.quote; if marker != '"' &...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/util/check_rule.rs
Rust
//! JS equivalent https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/util/check-rule.js use crate::state::State; use alloc::{boxed::Box, format}; use markdown::message::Message; pub fn check_rule(state: &State) -> Result<char, Message> { let marker = state.options.rule; if marker != '*' && m...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/util/check_rule_repetition.rs
Rust
//! JS equivalent https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/util/check-rule-repetition.js use crate::state::State; use alloc::{boxed::Box, format}; use markdown::message::Message; pub fn check_rule_repetition(state: &State) -> Result<u32, Message> { let repetition = state.options.rule_re...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus
mdast_util_to_markdown/src/util/check_strong.rs
Rust
//! JS equivalent https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/util/check-strong.js use crate::state::State; use alloc::{boxed::Box, format}; use markdown::message::Message; pub fn check_strong(state: &State) -> Result<char, Message> { let marker = state.options.strong; if marker != '*...
wooorm/markdown-rs
1,459
CommonMark compliant markdown parser in Rust with ASTs and extensions
Rust
wooorm
Titus