Skip to content

Instantly share code, notes, and snippets.

@tayiorbeii
Created October 14, 2022 15:09
Show Gist options
  • Save tayiorbeii/54731c73227a7d70f3c94f29bbb842b0 to your computer and use it in GitHub Desktop.
Save tayiorbeii/54731c73227a7d70f3c94f29bbb842b0 to your computer and use it in GitHub Desktop.
import "@johnlindquist/kit"
// Name:
let replaceAll = await npm('just-replace-all')
let chunkArray = await npm('chunk')
let txtFiles = await drop()
for (let f of txtFiles) {
let text = await readFile(`${f.path}`, 'utf-8')
let outdentedTextLines = text.split('\n')
let paragraphsArray = chunkArray(outdentedTextLines, 4)
let paragraphs = replaceAll(paragraphsArray.map(x => x.join('. ')).join('\n\n\n'), '..', '. ')
await writeFile(`${f.path}`, paragraphs)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment