Something went wrong. Try again.
Small (but incredibly useful!) scripts and utilities that don't need their own repo.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243#!/usr/bin/env nu# SPDX-License-Identifier: AGPL-3.0-only# Copyright (c) 2026 MatrixFurry <matrix@matrixfurry.com>
# Replace content between `<a data-tag>` elements in a markdown file## Allows you to directly edit the static parts of your markdown files without# using templates, while also being able to update the content that is# auto-generated by your CI scripts.## This is useful, for example, to keep package lists and descriptions# up to date, and is used in this repo (see [`meta/update-readme.nu`](./meta/update-readme.nu))!export def main [ tag: string body: string path?: path]: [ nothing -> nothing string -> string] { let pipeline = $in != null let input = $in
if not $pipeline and not ($path | path exists) { error make -u { msg: $"Could not open the specified file: `($path)`" } }
if $pipeline { $input } else { open $path --raw } | str replace --regex $"\(?s\)\(?<=<a data-tag=\"($tag)\">\).*?\(?=</a>\)" $body | if $pipeline { $in } else { collect | save -f $path }}