Skip to content

bkmcleod/CAMPost

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

<title>Text Transformer</title> <style> body { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; margin: 0; padding: 1.5rem; max-width: 960px; } h1 { font-size: 1.5rem; margin-bottom: 0.5rem; } .layout { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; } textarea { width: 100%; min-height: 260px; box-sizing: border-box; padding: 0.5rem; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 0.9rem; resize: vertical; } .controls { margin-top: 0.75rem; display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; align-items: center; } .checkbox-group { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.75rem; } label { font-size: 0.85rem; display: inline-flex; align-items: center; gap: 0.35rem; cursor: pointer; } button { padding: 0.4rem 0.9rem; border-radius: 4px; border: 1px solid #555; background: #f2f2f2; font-size: 0.9rem; cursor: pointer; } button:hover { filter: brightness(0.96); } .small { font-size: 0.75rem; color: #666; } @media (max-width: 800px) { .layout { grid-template-columns: 1fr; } } </style>

Text Transformer

Paste text on the left, choose transformations, then click "Transform".

Input

<textarea id="inputText" placeholder="Paste your text here"></textarea>

Output

<textarea id="outputText" readonly placeholder="Result appears here"></textarea>
Trim leading/trailing whitespace Collapse multiple spaces to a single space Normalize Windows/Mac newlines to "\n" Convert to UPPERCASE Remove completely blank lines
Transform Copy output
<script> // Core transformation pipeline definition. // Each entry: { id: 'checkboxId', fn: text => newText } const TRANSFORMS = [ { id: "cbTrim", fn: text => text.trim() }, { id: "cbCollapseSpaces", fn: text => text.replace(/ {2,}/g, " ") }, { id: "cbNormalizeNewlines", fn: text => text.replace(/\r\n?/g, "\n") }, { id: "cbUppercase", fn: text => text.toUpperCase() }, { id: "cbRemoveBlankLines", fn: text => text .split(/\r?\n/) .filter(line => line.trim() !== "") .join("\n") } // Add more transformation objects here ]; const inputEl = document.getElementById("inputText"); const outputEl = document.getElementById("outputText"); const statusEl = document.getElementById("status"); const btnTransform = document.getElementById("btnTransform"); const btnCopy = document.getElementById("btnCopy"); function runPipeline() { let text = inputEl.value; for (const t of TRANSFORMS) { const checkbox = document.getElementById(t.id); if (checkbox && checkbox.checked) { text = t.fn(text); } } outputEl.value = text; statusEl.textContent = "Transformed at " + new Date().toLocaleTimeString(); } btnTransform.addEventListener("click", runPipeline); btnCopy.addEventListener("click", async () => { try { await navigator.clipboard.writeText(outputEl.value); statusEl.textContent = "Output copied to clipboard"; } catch (err) { statusEl.textContent = "Copy failed (browser permissions)"; } }); // Optional: auto-run when input changes // inputEl.addEventListener("input", runPipeline); </script>

About

Post processor for OnShape CAM To add some custom automations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published