Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Scripts/WrapLines.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
{
"api": 1,
"name": "Wrap Lines",
"description": "Adds a line break after 77 characters",
"author": "Rex",
"icon": "scissors",
"tags": "line break,line,wrap,wrap lines"
}
**/

function main(state) {
state.text = wrapText(state.text);
}

function wrapText(text, length = 77) {
return text.replace(new RegExp(`(.{1,${length}})`, 'g'), '$1\n');
}