pdf-tools/util/dedent.ts
Emma 9535222fb7 improves block functionality
adds cli compatible prompts/logs
adds logfile function for debug
adds multiselect support
new fieldRename
adds listFieldNames
2025-04-30 01:17:45 -06:00

19 lines
511 B
TypeScript

export function dedent(str: string) {
const lines = str.split("\n");
const indent = lines.reduce((count, line) => {
if (line.trim() === "") return count;
const match = line.match(/^(\s*)/);
return match ? Math.min(count, match[1].length) : count;
}, Infinity);
return lines.map((line) => line.slice(indent)).join("\n");
}
if (import.meta.main) {
console.log(dedent(`
Hello, World!
This is a paragraph
that spans multiple lines.
And this is another paragraph.
`));
}