Added helper files

This commit is contained in:
Roberto Alsina 2024-08-09 10:30:20 -03:00
parent d3439563f2
commit 5c074344d5
3 changed files with 24 additions and 9 deletions

7
Makefile Normal file
View File

@ -0,0 +1,7 @@
build: $(wildcard src/**/*.cr) $(wildcard lexers/*xml) $(wildcard styles/*xml) shard.yml
shards build -Dstrict_multi_assign -Dno_number_autocast
release: $(wildcard src/**/*.cr) $(wildcard lexers/*xml) $(wildcard styles/*xml) shard.yml
shards build --release
static: $(wildcard src/**/*.cr) $(wildcard lexers/*xml) $(wildcard styles/*xml) shard.yml
shards build --release --static
strip bin/tartrazine

16
build_static.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
set -e
docker run --rm --privileged \
multiarch/qemu-user-static \
--reset -p yes
# Build for AMD64
docker build . -f Dockerfile.static -t tartrazine-builder
docker run -ti --rm -v "$PWD":/app --user="$UID" tartrazine-builder /bin/sh -c "cd /app && rm -rf lib shard.lock && make static"
mv bin/tartrazine bin/tartrazine-static-linux-amd64
# Build for ARM64
docker build . -f Dockerfile.static --platform linux/arm64 -t tartrazine-builder
docker run -ti --rm -v "$PWD":/app --platform linux/arm64 --user="$UID" tartrazine-builder /bin/sh -c "cd /app && rm -rf lib shard.lock && make static"
mv bin/tartrazine bin/tartrazine-static-linux-arm64

View File

@ -44,21 +44,13 @@ module Tartrazine
theme.styles.has_key?(parent)
}]
end
colorized = text.colorize(*rgb(s.color))
colorized = text.colorize(s.color.try &.colorize)
# Intentionally not setting background color
colorized.mode(:bold) if s.bold
colorized.mode(:italic) if s.italic
colorized.mode(:underline) if s.underline
colorized.to_s
end
def rgb(c : String?)
return {0_u8, 0_u8, 0_u8} unless c
r = c[0..1].to_u8(16)
g = c[2..3].to_u8(16)
b = c[4..5].to_u8(16)
{r, g, b}
end
end
class Html < Formatter