From 084a2967ef03f39519a4792c89f10e20d8ad8c4a Mon Sep 17 00:00:00 2001 From: borja Date: Thu, 13 Mar 2025 16:18:34 +0100 Subject: [PATCH] whi2html, marker para convertir pdfs a texto y mas o menos eso --- check_stats.sh | 9 +++- marker | 1 + marker_chunk_convert | 1 + marker_gui | 1 + marker_server | 1 + marker_single | 1 + streamlit | 1 + streamlit.cmd | 1 + whi2html.js | 97 ++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 111 insertions(+), 2 deletions(-) create mode 120000 marker create mode 120000 marker_chunk_convert create mode 120000 marker_gui create mode 120000 marker_server create mode 120000 marker_single create mode 120000 streamlit create mode 120000 streamlit.cmd create mode 100755 whi2html.js diff --git a/check_stats.sh b/check_stats.sh index d83534b..1c7d5a4 100755 --- a/check_stats.sh +++ b/check_stats.sh @@ -9,11 +9,16 @@ processes=( "/Applications/Stats.app/Contents/MacOS/Stats" ) +# # Function to check if a process is running +# check_process() { +# local process=$1 +# pgrep -f "$process" >/dev/null +# } -# Function to check if a process is running +# Function returns true if it finds at least 2 processes running, false if 1 or 0 check_process() { local process=$1 - pgrep -f "$process" >/dev/null + pgrep -f "$process" | wc -l } # Check each process and restart Stats.app if necessary diff --git a/marker b/marker new file mode 120000 index 0000000..4110cbf --- /dev/null +++ b/marker @@ -0,0 +1 @@ +/Users/borjarobert/.local/pipx/venvs/marker-pdf/bin/marker \ No newline at end of file diff --git a/marker_chunk_convert b/marker_chunk_convert new file mode 120000 index 0000000..0b541b0 --- /dev/null +++ b/marker_chunk_convert @@ -0,0 +1 @@ +/Users/borjarobert/.local/pipx/venvs/marker-pdf/bin/marker_chunk_convert \ No newline at end of file diff --git a/marker_gui b/marker_gui new file mode 120000 index 0000000..3c52f8b --- /dev/null +++ b/marker_gui @@ -0,0 +1 @@ +/Users/borjarobert/.local/pipx/venvs/marker-pdf/bin/marker_gui \ No newline at end of file diff --git a/marker_server b/marker_server new file mode 120000 index 0000000..9893942 --- /dev/null +++ b/marker_server @@ -0,0 +1 @@ +/Users/borjarobert/.local/pipx/venvs/marker-pdf/bin/marker_server \ No newline at end of file diff --git a/marker_single b/marker_single new file mode 120000 index 0000000..1c537b0 --- /dev/null +++ b/marker_single @@ -0,0 +1 @@ +/Users/borjarobert/.local/pipx/venvs/marker-pdf/bin/marker_single \ No newline at end of file diff --git a/streamlit b/streamlit new file mode 120000 index 0000000..9b09011 --- /dev/null +++ b/streamlit @@ -0,0 +1 @@ +/Users/borjarobert/.local/pipx/venvs/streamlit/bin/streamlit \ No newline at end of file diff --git a/streamlit.cmd b/streamlit.cmd new file mode 120000 index 0000000..088755a --- /dev/null +++ b/streamlit.cmd @@ -0,0 +1 @@ +/Users/borjarobert/.local/pipx/venvs/streamlit/bin/streamlit.cmd \ No newline at end of file diff --git a/whi2html.js b/whi2html.js new file mode 100755 index 0000000..8c8283b --- /dev/null +++ b/whi2html.js @@ -0,0 +1,97 @@ +#!/usr/bin/env bun + +// Import the required modules +import { readFile, writeFile } from 'fs/promises'; +import { argv } from 'process'; + +// Function to generate HTML from the input text +async function generateHTML(inputFile) { + try { + // Read the input file + const data = await readFile(inputFile, 'utf-8'); + + // Split the data into lines + const lines = data.split('\n').filter(line => line.trim() !== ''); + + // Start building the HTML content + let htmlContent = ` + + + + + + ${inputFile} + + + + + + `; + + // Process each line and add it to the HTML content + lines.forEach(line => { + // Split the line at the first closing bracket + const parts = line.split(']'); + if (parts.length >= 2) { + const timestamp = parts[0].replace('[', '').trim(); // Clean the timestamp + const text = parts[1].trim(); // Clean the text + htmlContent += ` + + + + + `; + } + }); + + // Close the HTML tags + htmlContent += ` + +
${timestamp}${text}
+ + + `; + + // Write the HTML content to a file + const outputFile = inputFile.replace('.txt', '.html'); + await writeFile(outputFile, htmlContent); + console.log(`HTML file created: ${outputFile}`); + } catch (error) { + console.error('Error:', error); + } +} + +// Get the input file from command line arguments +const inputFile = argv[2]; +if (!inputFile) { + console.error('Please provide a text file as an argument.'); +} else { + generateHTML(inputFile); +}