mirror of
https://github.com/mfontanini/presenterm.git
synced 2026-09-01 23:33:21 -06:00
Add PDF generation test
This commit is contained in:
parent
ffebede467
commit
804a8ebb10
@ -1,29 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
def migrate_color(line: str) -> str:
|
||||
def as_hex(number_str: str) -> int:
|
||||
number = int(number_str)
|
||||
return f"{number:02x}"
|
||||
|
||||
matches = re.match(r'.*"rgb_\(([\d]+),([\d]+),([\d]+)\)"', line)
|
||||
if not matches:
|
||||
return line
|
||||
hex_color = "".join(map(as_hex, matches.group(1, 2, 3)))
|
||||
original_color = f"rgb_({matches[1]},{matches[2]},{matches[3]})"
|
||||
return line.replace(original_color, hex_color)
|
||||
|
||||
|
||||
def migrate(line: str) -> str:
|
||||
migrators = [migrate_color]
|
||||
for migrator in migrators:
|
||||
line = migrator(line)
|
||||
return line
|
||||
|
||||
|
||||
for line in sys.stdin:
|
||||
new_line = migrate(line)
|
||||
sys.stdout.write(new_line)
|
||||
29
scripts/test-pdf-generation.sh
Executable file
29
scripts/test-pdf-generation.sh
Executable file
@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
script_dir=$(dirname "$0")
|
||||
root_dir=$(realpath "${script_dir}/../")
|
||||
|
||||
echo "Creating python env"
|
||||
env_dir=$(mktemp -d)
|
||||
trap 'rm -rf "${env_dir}"' EXIT
|
||||
python -mvenv "${env_dir}/pyenv"
|
||||
source "${env_dir}/pyenv/bin/activate"
|
||||
|
||||
echo "Installing presenterm-export==0.1.2"
|
||||
pip install presenterm-export
|
||||
|
||||
echo "Running presenterm..."
|
||||
rm -f "${root_dir}/examples/demo.pdf"
|
||||
cargo run -q -- --export-pdf "${root_dir}/examples/demo.md"
|
||||
|
||||
if test -f "${root_dir}/examples/demo.pdf"
|
||||
then
|
||||
echo "PDF file has been created"
|
||||
rm -f "${root_dir}/examples/demo.pdf"
|
||||
else
|
||||
echo "PDF file does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -85,6 +85,7 @@ fn run(cli: Cli) -> Result<(), Box<dyn std::error::Error>> {
|
||||
fn main() {
|
||||
let cli = Cli::parse();
|
||||
if let Err(e) = run(cli) {
|
||||
eprintln!("Failed to run presentation: {e}");
|
||||
eprintln!("{e}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user