Trim script and style elements

This commit is contained in:
Wilson Lin 2021-08-10 17:35:14 +10:00
commit ca30897dae
9 changed files with 49 additions and 8 deletions

View file

@ -1,14 +1,18 @@
#!/usr/bin/env bash
set -Eeuo pipefail
set -Eeo pipefail
pushd "$(dirname "$0")" >/dev/null
cargo build --manifest-path c14n/Cargo.toml --release
cargo build --manifest-path charlines/Cargo.toml --release
for f in outputs/*/*; do
src=$(cat "$f")
c14n/target/release/c14n <<< "$src" > "$f"
out=$(c14n/target/release/c14n < "$f")
if [[ "$CHARLINES" == "1" ]]; then
out=$(charlines/target/release/charlines <<< "$out")
fi
cat <<< "$out" > "$f"
done
popd >/dev/null

2
debug/diff/charlines/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/Cargo.lock
/target/

View file

@ -0,0 +1,5 @@
[package]
publish = false
name = "charlines"
version = "0.0.1"
edition = "2018"

View file

@ -0,0 +1,3 @@
# charlines
Output each character from stdin onto its own stdout line. Useful for subsequence diffing when text does not naturally have a lot of line breaks (e.g. minified HTML).

View file

@ -0,0 +1,10 @@
use std::io::{stdin, stdout, Read, Write};
fn main() {
let mut src = Vec::new();
stdin().read_to_end(&mut src).unwrap();
let mut out = stdout();
for c in src {
out.write_all(&[c, b'\n']).unwrap();
}
}