From c502e3e1801e77723a89d3becdd42e85c2cd312b Mon Sep 17 00:00:00 2001 From: Rene Kudlek Date: Tue, 4 Mar 2025 11:14:59 +0100 Subject: [PATCH 1/2] Add wrap lines script --- Scripts/WrapLines.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Scripts/WrapLines.js diff --git a/Scripts/WrapLines.js b/Scripts/WrapLines.js new file mode 100644 index 00000000..7d304427 --- /dev/null +++ b/Scripts/WrapLines.js @@ -0,0 +1,18 @@ +/** + { + "api": 1, + "name": "Wrap Lines", + "description": "Adds a line break after 77 characters", + "author": "Rex", + "icon": "scissors", + "tags": "linebreak,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'); +} From c83bfdd09e2be51e12cf1a010a28d4e05d3fdcc2 Mon Sep 17 00:00:00 2001 From: Rene Kudlek Date: Tue, 4 Mar 2025 11:20:47 +0100 Subject: [PATCH 2/2] typo --- Scripts/WrapLines.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/WrapLines.js b/Scripts/WrapLines.js index 7d304427..5044da9c 100644 --- a/Scripts/WrapLines.js +++ b/Scripts/WrapLines.js @@ -5,7 +5,7 @@ "description": "Adds a line break after 77 characters", "author": "Rex", "icon": "scissors", - "tags": "linebreak,line,wrap,wrap lines" + "tags": "line break,line,wrap,wrap lines" } **/