mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-30 00:50:47 +03:00
feat(new tool): Whitespace cleaner tool
Add a tool that cleans terminal and Claude Code output. The cleaner strips line numbers, ANSI escape sequences, box drawing, bullet markers, diff markers, trailing whitespace, and the common indent. Smart unwrap and Markdown / Reddit mode are optional. Options persist in localStorage. The pasted input is not saved. Co-Authored-By: @destan Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PEUYi2gRxcytxRFXjPjH3U
This commit is contained in:
committed
1 parent
6e021e9848
commit
8974b3048d
9 files changed
+1529
-42
No files matched your search
+150
-42
@@ -53,7 +53,8 @@ about:
|
|||||||
favorites-imported-successfully: Favorites imported successfully!
|
favorites-imported-successfully: Favorites imported successfully!
|
||||||
error-importing-favorites-e: 'Error importing favorites: {0}'
|
error-importing-favorites-e: 'Error importing favorites: {0}'
|
||||||
text:
|
text:
|
||||||
collection-of-handy-online-tools-for-developers-with-great-ux-it-tools-is-a-free-and-open-source-collection-of-handy-online-tools-for-developers-and-people-working-in-it: >-
|
collection-of-handy-online-tools-for-developers-with-great-ux-it-tools-is-a-free-and-open-source-collection-of-handy-online-tools-for-developers-and-people-working-in-it:
|
||||||
|
>-
|
||||||
Collection of handy online tools for developers, with great UX. IT Tools
|
Collection of handy online tools for developers, with great UX. IT Tools
|
||||||
is a free and open-source collection of handy online tools for developers
|
is a free and open-source collection of handy online tools for developers
|
||||||
& people working in IT.
|
& people working in IT.
|
||||||
@@ -120,7 +121,8 @@ home:
|
|||||||
themeDark: Dark
|
themeDark: Dark
|
||||||
page:
|
page:
|
||||||
text:
|
text:
|
||||||
collection-of-handy-online-tools-for-developers-with-great-ux-it-tools-is-a-free-and-open-source-collection-of-handy-online-tools-for-developers-and-people-working-in-it: >-
|
collection-of-handy-online-tools-for-developers-with-great-ux-it-tools-is-a-free-and-open-source-collection-of-handy-online-tools-for-developers-and-people-working-in-it:
|
||||||
|
>-
|
||||||
Collection of handy online tools for developers, with great UX. IT Tools
|
Collection of handy online tools for developers, with great UX. IT Tools
|
||||||
is a free and open-source collection of handy online tools for
|
is a free and open-source collection of handy online tools for
|
||||||
developers & people working in IT.
|
developers & people working in IT.
|
||||||
@@ -1594,7 +1596,7 @@ tools:
|
|||||||
label-code-snippet-to-format: 'Code snippet to format:'
|
label-code-snippet-to-format: 'Code snippet to format:'
|
||||||
placeholder-put-your-code-snippet-here: Put your code snippet here
|
placeholder-put-your-code-snippet-here: Put your code snippet here
|
||||||
label-show-line-numbers: Show line numbers
|
label-show-line-numbers: Show line numbers
|
||||||
tag-: ''', '''
|
tag-: "', '"
|
||||||
tag-copy-html-formatted: Copy HTML Formatted
|
tag-copy-html-formatted: Copy HTML Formatted
|
||||||
tag-copy-code-text: Copy Code Text
|
tag-copy-code-text: Copy Code Text
|
||||||
tag-copy-html-word: Copy to HTML/Rich text in Word
|
tag-copy-html-word: Copy to HTML/Rich text in Word
|
||||||
@@ -2275,9 +2277,9 @@ tools:
|
|||||||
label-advanded-json-mode: Advanded JSON Mode
|
label-advanded-json-mode: Advanded JSON Mode
|
||||||
title-prompts: Prompts
|
title-prompts: Prompts
|
||||||
placeholder-your-messages-json-array: Your 'messages' JSON array...
|
placeholder-your-messages-json-array: Your 'messages' JSON array...
|
||||||
label-your-messages-json-array: 'Your ''messages'' JSON array:'
|
label-your-messages-json-array: "Your 'messages' JSON array:"
|
||||||
placeholder-your-tools-json-array: Your 'tools' JSON array...
|
placeholder-your-tools-json-array: Your 'tools' JSON array...
|
||||||
label-your-tools-json-array: 'Your ''tools'' JSON array:'
|
label-your-tools-json-array: "Your 'tools' JSON array:"
|
||||||
title-input-json-s: Input JSON(s)
|
title-input-json-s: Input JSON(s)
|
||||||
placeholder-your-system-prompt-content: Your System Prompt content...
|
placeholder-your-system-prompt-content: Your System Prompt content...
|
||||||
label-your-system-prompt-content: 'Your System Prompt content:'
|
label-your-system-prompt-content: 'Your System Prompt content:'
|
||||||
@@ -2853,7 +2855,7 @@ tools:
|
|||||||
verify-description: '{0}: {1} (verify with {2})'
|
verify-description: '{0}: {1} (verify with {2})'
|
||||||
token-secret: Token Secret
|
token-secret: Token Secret
|
||||||
token-keys: Token Keys
|
token-keys: Token Keys
|
||||||
cannot-parse-secret-as-encoding: 'Cannot parse ''{0}'' as ''{1}'': {2}'
|
cannot-parse-secret-as-encoding: "Cannot parse '{0}' as '{1}': {2}"
|
||||||
invalid-base64-string: Invalid Base64 string
|
invalid-base64-string: Invalid Base64 string
|
||||||
placeholder-input-token: Paste your JWT token to edit...
|
placeholder-input-token: Paste your JWT token to edit...
|
||||||
click-to-input-a-existing-jwt-token-to-modify: Click to input a existing JWT token to modify
|
click-to-input-a-existing-jwt-token-to-modify: Click to input a existing JWT token to modify
|
||||||
@@ -4174,7 +4176,8 @@ tools:
|
|||||||
placeholder-enter-cookie-header: Enter cookie header
|
placeholder-enter-cookie-header: Enter cookie header
|
||||||
tag-tip-navigate-to-a-website-to-test-open-f12-console-and-run: 'Tip: Navigate to a website to test, open F12 Console and run'
|
tag-tip-navigate-to-a-website-to-test-open-f12-console-and-run: 'Tip: Navigate to a website to test, open F12 Console and run'
|
||||||
tag-window-copy-document-cookie: window.copy(document.cookie)
|
tag-window-copy-document-cookie: window.copy(document.cookie)
|
||||||
tag-this-will-copy-the-cookie-string-to-your-clipboard-note-this-will-only-copy-cookies-available-to-javascript-http-only-and-secure-cookies-will-be-omitted: >-
|
tag-this-will-copy-the-cookie-string-to-your-clipboard-note-this-will-only-copy-cookies-available-to-javascript-http-only-and-secure-cookies-will-be-omitted:
|
||||||
|
>-
|
||||||
. This will copy the cookie string to your clipboard. Note: This will
|
. This will copy the cookie string to your clipboard. Note: This will
|
||||||
only copy cookies available to javascript (HTTP only and secure cookies
|
only copy cookies available to javascript (HTTP only and secure cookies
|
||||||
will be omitted).
|
will be omitted).
|
||||||
@@ -4866,25 +4869,29 @@ tools:
|
|||||||
label-custom-expression: 'Custom Expression:'
|
label-custom-expression: 'Custom Expression:'
|
||||||
placeholder-e-g-src-port-443-and-dst-10-0-0-1: e.g., src port 443 and dst 10.0.0.1
|
placeholder-e-g-src-port-443-and-dst-10-0-0-1: e.g., src port 443 and dst 10.0.0.1
|
||||||
title-generated-tcpdump-command: Generated tcpdump command
|
title-generated-tcpdump-command: Generated tcpdump command
|
||||||
tag-tcpdump-is-a-utility-commonly-installed-available-to-many-linux-distributions-to-quickly-gather-a-network-trace-packet-capture-in-short-it-s-the-wireshark-of-linux-to-gathering-packet-captures-tcpdump-is-very-versatile-with-many-switches-to-granularly-capture-what-you-need-to-dubug-network-traffic-with-options-to-output-results-via-console-file-or-wireshark-pcap: >-
|
tag-tcpdump-is-a-utility-commonly-installed-available-to-many-linux-distributions-to-quickly-gather-a-network-trace-packet-capture-in-short-it-s-the-wireshark-of-linux-to-gathering-packet-captures-tcpdump-is-very-versatile-with-many-switches-to-granularly-capture-what-you-need-to-dubug-network-traffic-with-options-to-output-results-via-console-file-or-wireshark-pcap:
|
||||||
|
>-
|
||||||
tcpdump is a utility commonly installed / available to many Linux
|
tcpdump is a utility commonly installed / available to many Linux
|
||||||
distributions to quickly gather a network trace / packet capture. In
|
distributions to quickly gather a network trace / packet capture. In
|
||||||
short, it's the wireshark of linux to gathering packet captures. tcpdump
|
short, it's the wireshark of linux to gathering packet captures. tcpdump
|
||||||
is very versatile with many switches to granularly capture what you need
|
is very versatile with many switches to granularly capture what you need
|
||||||
to dubug network traffic; with options to output results via console,
|
to dubug network traffic; with options to output results via console,
|
||||||
file, or wireshark pcap.
|
file, or wireshark pcap.
|
||||||
tag-this-utility-is-to-help-generate-a-tcpdump-command-using-some-of-the-more-common-switches-filters-offered-by-the-tcpdump-this-utility-is-not-encompassing-of-all-options-tcpdump-offers-a-complete-list-of-options-can-be-found-via-its-manual-nbsp: >-
|
tag-this-utility-is-to-help-generate-a-tcpdump-command-using-some-of-the-more-common-switches-filters-offered-by-the-tcpdump-this-utility-is-not-encompassing-of-all-options-tcpdump-offers-a-complete-list-of-options-can-be-found-via-its-manual-nbsp:
|
||||||
|
>-
|
||||||
This utility is to help generate a tcpdump command using some of the
|
This utility is to help generate a tcpdump command using some of the
|
||||||
more common switches / filters offered by the tcpdump. This utility is
|
more common switches / filters offered by the tcpdump. This utility is
|
||||||
not encompassing of all options tcpdump offers; a complete list of
|
not encompassing of all options tcpdump offers; a complete list of
|
||||||
options can be found via its manual:
|
options can be found via its manual:
|
||||||
tag-https-www-tcpdump-org-manpages-tcpdump-1-html: https://www.tcpdump.org/manpages/tcpdump.1.html
|
tag-https-www-tcpdump-org-manpages-tcpdump-1-html: https://www.tcpdump.org/manpages/tcpdump.1.html
|
||||||
tag-note: 'Note:'
|
tag-note: 'Note:'
|
||||||
tag-nbsp-host-source-host-and-destination-host-can-take-multiple-entries-separate-your-entries-with-a-comma-space-or-semicolon: >-
|
tag-nbsp-host-source-host-and-destination-host-can-take-multiple-entries-separate-your-entries-with-a-comma-space-or-semicolon:
|
||||||
|
>-
|
||||||
Host, Source Host, and Destination Host can take multiple entries.
|
Host, Source Host, and Destination Host can take multiple entries.
|
||||||
Separate your entries with a comma, space, or semicolon.
|
Separate your entries with a comma, space, or semicolon.
|
||||||
tag-note-2: 'Note 2:'
|
tag-note-2: 'Note 2:'
|
||||||
tag-nbsp-when-you-specify-a-source-src-or-destination-dst-flags-tcpdump-will-only-filter-in-that-direction-if-you-are-looking-to-capture-full-tcp-handshake-make-sure-you-use-host-vs-src-host-or-dst-host-to-see-both-request-and-response-flow: >-
|
tag-nbsp-when-you-specify-a-source-src-or-destination-dst-flags-tcpdump-will-only-filter-in-that-direction-if-you-are-looking-to-capture-full-tcp-handshake-make-sure-you-use-host-vs-src-host-or-dst-host-to-see-both-request-and-response-flow:
|
||||||
|
>-
|
||||||
When you specify a source (src) or destination (dst) flags,
|
When you specify a source (src) or destination (dst) flags,
|
||||||
tcpdump will only filter in that direction. If you are looking to
|
tcpdump will only filter in that direction. If you are looking to
|
||||||
capture full TCP handshake, make sure you use "host" vs "src host" or
|
capture full TCP handshake, make sure you use "host" vs "src host" or
|
||||||
@@ -5207,7 +5214,8 @@ tools:
|
|||||||
raid-70-requires-at-least-10-disks-with-5-minimum-per-stripe-stripes-must-contain-an-equal-number-of-disks: >-
|
raid-70-requires-at-least-10-disks-with-5-minimum-per-stripe-stripes-must-contain-an-equal-number-of-disks: >-
|
||||||
RAID 70 requires at least 10 disks with 5 minimum per stripe. Stripes
|
RAID 70 requires at least 10 disks with 5 minimum per stripe. Stripes
|
||||||
must contain an equal number of disks.
|
must contain an equal number of disks.
|
||||||
raid-70-stripes-multiple-raid-7-arrays-together-raid-7-raid-0-each-raid-7-set-can-sustain-three-drive-failures: >-
|
raid-70-stripes-multiple-raid-7-arrays-together-raid-7-raid-0-each-raid-7-set-can-sustain-three-drive-failures:
|
||||||
|
>-
|
||||||
RAID 70 stripes multiple RAID 7 arrays together (RAID 7 + RAID 0).
|
RAID 70 stripes multiple RAID 7 arrays together (RAID 7 + RAID 0).
|
||||||
Each RAID 7 set can sustain three drive failures.
|
Each RAID 7 set can sustain three drive failures.
|
||||||
2-drive-failures-per-raid-6-set: 2 drive failures per RAID 6 set
|
2-drive-failures-per-raid-6-set: 2 drive failures per RAID 6 set
|
||||||
@@ -5221,40 +5229,47 @@ tools:
|
|||||||
raid-50-requires-at-least-6-disks-with-3-minimum-per-stripe-stripes-must-contain-an-equal-number-of-disks: >-
|
raid-50-requires-at-least-6-disks-with-3-minimum-per-stripe-stripes-must-contain-an-equal-number-of-disks: >-
|
||||||
RAID 50 requires at least 6 disks with 3 minimum per stripe. Stripes
|
RAID 50 requires at least 6 disks with 3 minimum per stripe. Stripes
|
||||||
must contain an equal number of disks.
|
must contain an equal number of disks.
|
||||||
raid-50-stripes-multiple-raid-5-arrays-together-raid-5-raid-0-each-raid-5-set-can-sustain-a-single-drive-failure: >-
|
raid-50-stripes-multiple-raid-5-arrays-together-raid-5-raid-0-each-raid-5-set-can-sustain-a-single-drive-failure:
|
||||||
|
>-
|
||||||
RAID 50 stripes multiple RAID 5 arrays together (RAID 5 + RAID 0).
|
RAID 50 stripes multiple RAID 5 arrays together (RAID 5 + RAID 0).
|
||||||
Each RAID 5 set can sustain a single drive failure.
|
Each RAID 5 set can sustain a single drive failure.
|
||||||
1-drive-failure-per-mirrored-set: 1 drive failure per mirrored set
|
1-drive-failure-per-mirrored-set: 1 drive failure per mirrored set
|
||||||
raid-10-requires-an-even-number-of-at-least-4-disks: RAID 10 requires an even number of at least 4 disks
|
raid-10-requires-an-even-number-of-at-least-4-disks: RAID 10 requires an even number of at least 4 disks
|
||||||
raid-10-is-a-stripe-of-mirrors-raid-1-raid-0-each-set-of-drives-is-mirrored-and-striped-together-so-that-each-drive-in-the-set-is-fault-tolerant-within-the-group: >-
|
raid-10-is-a-stripe-of-mirrors-raid-1-raid-0-each-set-of-drives-is-mirrored-and-striped-together-so-that-each-drive-in-the-set-is-fault-tolerant-within-the-group:
|
||||||
|
>-
|
||||||
RAID 10 is a stripe of mirrors (RAID 1 + RAID 0). Each set of drives
|
RAID 10 is a stripe of mirrors (RAID 1 + RAID 0). Each set of drives
|
||||||
is mirrored and striped together so that each drive in the set is
|
is mirrored and striped together so that each drive in the set is
|
||||||
fault tolerant within the group.
|
fault tolerant within the group.
|
||||||
3-drive-failures: 3 drive failures
|
3-drive-failures: 3 drive failures
|
||||||
raid-7-requires-at-least-5-disks: RAID 7 requires at least 5 disks
|
raid-7-requires-at-least-5-disks: RAID 7 requires at least 5 disks
|
||||||
raid-7-raid-tp-non-standard-is-similiar-to-raid-5-and-raid-6-but-with-a-third-parity-block-this-allows-for-a-third-disk-failure-at-the-cost-of-storage-reduction-equal-to-three-drives: >-
|
raid-7-raid-tp-non-standard-is-similiar-to-raid-5-and-raid-6-but-with-a-third-parity-block-this-allows-for-a-third-disk-failure-at-the-cost-of-storage-reduction-equal-to-three-drives:
|
||||||
|
>-
|
||||||
RAID 7/RAID TP (non-standard) is similiar to RAID 5 and RAID 6 but
|
RAID 7/RAID TP (non-standard) is similiar to RAID 5 and RAID 6 but
|
||||||
with a third parity block. This allows for a third disk failure at the
|
with a third parity block. This allows for a third disk failure at the
|
||||||
cost of storage reduction equal to three drives.
|
cost of storage reduction equal to three drives.
|
||||||
2-drive-failures: 2 drive failures
|
2-drive-failures: 2 drive failures
|
||||||
raid-6-requires-at-least-4-disks: RAID 6 requires at least 4 disks
|
raid-6-requires-at-least-4-disks: RAID 6 requires at least 4 disks
|
||||||
raid-6-is-similiar-to-raid-5-but-with-an-additional-parity-block-this-allows-for-an-additional-disk-failure-at-the-cost-of-storage-reduction-equal-to-two-drives: >-
|
raid-6-is-similiar-to-raid-5-but-with-an-additional-parity-block-this-allows-for-an-additional-disk-failure-at-the-cost-of-storage-reduction-equal-to-two-drives:
|
||||||
|
>-
|
||||||
RAID 6 is similiar to RAID 5 but with an additional parity block. This
|
RAID 6 is similiar to RAID 5 but with an additional parity block. This
|
||||||
allows for an additional disk failure at the cost of storage reduction
|
allows for an additional disk failure at the cost of storage reduction
|
||||||
equal to two drives.
|
equal to two drives.
|
||||||
1-drive-failure: 1 drive failure
|
1-drive-failure: 1 drive failure
|
||||||
raid-5-requires-at-least-3-disks: RAID 5 requires at least 3 disks
|
raid-5-requires-at-least-3-disks: RAID 5 requires at least 3 disks
|
||||||
raid-5-uses-block-level-striping-with-parity-this-allows-for-fault-tolerance-with-a-storage-reduction-equal-to-one-drive-for-the-parity-information: >-
|
raid-5-uses-block-level-striping-with-parity-this-allows-for-fault-tolerance-with-a-storage-reduction-equal-to-one-drive-for-the-parity-information:
|
||||||
|
>-
|
||||||
RAID 5 uses block level striping with parity. This allows for fault
|
RAID 5 uses block level striping with parity. This allows for fault
|
||||||
tolerance with a storage reduction equal to one drive for the parity
|
tolerance with a storage reduction equal to one drive for the parity
|
||||||
information.
|
information.
|
||||||
raid-1-requires-at-least-1-disk: RAID 1 requires at least 1 disk
|
raid-1-requires-at-least-1-disk: RAID 1 requires at least 1 disk
|
||||||
raid-1-consists-of-an-exact-copy-of-the-data-mirror-across-two-or-more-disks-the-array-will-operate-as-long-as-at-least-one-drive-is-operational: >-
|
raid-1-consists-of-an-exact-copy-of-the-data-mirror-across-two-or-more-disks-the-array-will-operate-as-long-as-at-least-one-drive-is-operational:
|
||||||
|
>-
|
||||||
RAID 1 consists of an exact copy of the data (mirror) across two or
|
RAID 1 consists of an exact copy of the data (mirror) across two or
|
||||||
more disks. The array will operate as long as at least one drive is
|
more disks. The array will operate as long as at least one drive is
|
||||||
operational.
|
operational.
|
||||||
raid-0-requires-at-least-1-disk: RAID 0 requires at least 1 disk
|
raid-0-requires-at-least-1-disk: RAID 0 requires at least 1 disk
|
||||||
raid-0-splits-data-evenly-across-2-or-more-disks-without-redunancy-or-fault-tolerance-creating-one-large-storage-space: >-
|
raid-0-splits-data-evenly-across-2-or-more-disks-without-redunancy-or-fault-tolerance-creating-one-large-storage-space:
|
||||||
|
>-
|
||||||
RAID 0 splits data evenly across 2 or more disks without redunancy or
|
RAID 0 splits data evenly across 2 or more disks without redunancy or
|
||||||
fault tolerance creating one large storage space.
|
fault tolerance creating one large storage space.
|
||||||
categories:
|
categories:
|
||||||
@@ -5396,14 +5411,16 @@ tools:
|
|||||||
text:
|
text:
|
||||||
source-wikipedia: 'Source: Wikipedia'
|
source-wikipedia: 'Source: Wikipedia'
|
||||||
once-the-long-break-is-finished-return-to-step-1: Once the long break is finished, return to Step 1.
|
once-the-long-break-is-finished-return-to-step-1: Once the long break is finished, return to Step 1.
|
||||||
keep-repeating-steps-1-3-but-after-your-4th-task-take-a-long-break-instead-of-a-short-break-20-30-minutes-is-common: >-
|
keep-repeating-steps-1-3-but-after-your-4th-task-take-a-long-break-instead-of-a-short-break-20-30-minutes-is-common:
|
||||||
|
>-
|
||||||
Keep repeating Steps 1-3, but after your 4th task, take a long break
|
Keep repeating Steps 1-3, but after your 4th task, take a long break
|
||||||
instead of a short break (20-30 minutes is common).
|
instead of a short break (20-30 minutes is common).
|
||||||
when-the-timer-rings-take-a-short-break-5-10-minutes-is-common: When the timer rings, take a short break (5-10 minutes is common).
|
when-the-timer-rings-take-a-short-break-5-10-minutes-is-common: When the timer rings, take a short break (5-10 minutes is common).
|
||||||
work-on-the-task-during-that-time: Work on the task during that time.
|
work-on-the-task-during-that-time: Work on the task during that time.
|
||||||
decide-on-a-task-and-set-the-timer-25-minutes-is-common: Decide on a task and set the timer (25 minutes is common).
|
decide-on-a-task-and-set-the-timer-25-minutes-is-common: Decide on a task and set the timer (25 minutes is common).
|
||||||
five-steps-of-the-pomodoro-technique: Five steps of the Pomodoro Technique
|
five-steps-of-the-pomodoro-technique: Five steps of the Pomodoro Technique
|
||||||
the-pomodoro-technique-is-a-time-management-method-developed-by-francesco-cirillo-in-the-1980s-it-uses-a-timer-to-break-work-into-intervals-typically-25-minutes-in-length-separated-by-short-breaks-each-interval-is-known-as-a-pomodoro-from-the-italian-word-for-tomato-after-the-tomato-shaped-kitchen-timer-cirillo-used-as-a-university-student: >-
|
the-pomodoro-technique-is-a-time-management-method-developed-by-francesco-cirillo-in-the-1980s-it-uses-a-timer-to-break-work-into-intervals-typically-25-minutes-in-length-separated-by-short-breaks-each-interval-is-known-as-a-pomodoro-from-the-italian-word-for-tomato-after-the-tomato-shaped-kitchen-timer-cirillo-used-as-a-university-student:
|
||||||
|
>-
|
||||||
The Pomodoro Technique is a time management method developed by
|
The Pomodoro Technique is a time management method developed by
|
||||||
Francesco Cirillo in the 1980s. It uses a timer to break work into
|
Francesco Cirillo in the 1980s. It uses a timer to break work into
|
||||||
intervals, typically 25 minutes in length, separated by short breaks.
|
intervals, typically 25 minutes in length, separated by short breaks.
|
||||||
@@ -5615,7 +5632,7 @@ tools:
|
|||||||
service:
|
service:
|
||||||
text:
|
text:
|
||||||
invalid-octal-permissions-must-be-3-or-4-octal-digits-octalpermissions: 'Invalid octal permissions (must be 3 or 4 octal digits): {0}'
|
invalid-octal-permissions-must-be-3-or-4-octal-digits-octalpermissions: 'Invalid octal permissions (must be 3 or 4 octal digits): {0}'
|
||||||
invalid-string-permissions-must-be-in-form-rwxrwxrwx-symbolicpermissions: 'Invalid string permissions (must be in form ''rwxrwxrwx''): {0}'
|
invalid-string-permissions-must-be-in-form-rwxrwxrwx-symbolicpermissions: "Invalid string permissions (must be in form 'rwxrwxrwx'): {0}"
|
||||||
color-converter:
|
color-converter:
|
||||||
title: Color converter
|
title: Color converter
|
||||||
description: Convert color between the different formats (hex, rgb, hsl and css name)
|
description: Convert color between the different formats (hex, rgb, hsl and css name)
|
||||||
@@ -5653,7 +5670,8 @@ tools:
|
|||||||
placeholder-enter-a-password: Enter a password...
|
placeholder-enter-a-password: Enter a password...
|
||||||
tag-duration-to-crack-this-password-with-brute-force: Duration to crack this password with brute force
|
tag-duration-to-crack-this-password-with-brute-force: Duration to crack this password with brute force
|
||||||
tag-note: 'Note:'
|
tag-note: 'Note:'
|
||||||
tag-the-computed-strength-is-based-on-the-time-it-would-take-to-crack-the-password-using-a-brute-force-approach-it-does-not-take-into-account-the-possibility-of-a-dictionary-attack: >-
|
tag-the-computed-strength-is-based-on-the-time-it-would-take-to-crack-the-password-using-a-brute-force-approach-it-does-not-take-into-account-the-possibility-of-a-dictionary-attack:
|
||||||
|
>-
|
||||||
The computed strength is based on the time it would take to crack the
|
The computed strength is based on the time it would take to crack the
|
||||||
password using a brute force approach, it does not take into account the
|
password using a brute force approach, it does not take into account the
|
||||||
possibility of a dictionary attack.
|
possibility of a dictionary attack.
|
||||||
@@ -5835,7 +5853,7 @@ tools:
|
|||||||
song-details: Song details
|
song-details: Song details
|
||||||
twitter:
|
twitter:
|
||||||
text:
|
text:
|
||||||
the-name-of-the-twitter-account-of-the-creator-ex-sharevb: 'The name of the Twitter account of the creator (ex: {''@''}sharevb)...'
|
the-name-of-the-twitter-account-of-the-creator-ex-sharevb: "The name of the Twitter account of the creator (ex: {'@'}sharevb)..."
|
||||||
creator-acc: Creator acc.
|
creator-acc: Creator acc.
|
||||||
the-name-of-the-twitter-account-of-the-site-ex-ittoolsdottech: >-
|
the-name-of-the-twitter-account-of-the-site-ex-ittoolsdottech: >-
|
||||||
The name of the Twitter account of the site (ex:
|
The name of the Twitter account of the site (ex:
|
||||||
@@ -6618,17 +6636,20 @@ tools:
|
|||||||
The server either does not recognize the request method, or it lacks
|
The server either does not recognize the request method, or it lacks
|
||||||
the ability to fulfill the request.
|
the ability to fulfill the request.
|
||||||
not-implemented: Not Implemented
|
not-implemented: Not Implemented
|
||||||
a-generic-error-message-given-when-an-unexpected-condition-was-encountered-and-no-more-specific-message-is-suitable: >-
|
a-generic-error-message-given-when-an-unexpected-condition-was-encountered-and-no-more-specific-message-is-suitable:
|
||||||
|
>-
|
||||||
A generic error message, given when an unexpected condition was
|
A generic error message, given when an unexpected condition was
|
||||||
encountered and no more specific message is suitable.
|
encountered and no more specific message is suitable.
|
||||||
internal-server-error: Internal Server Error
|
internal-server-error: Internal Server Error
|
||||||
5xx-server-error: 5xx server error
|
5xx-server-error: 5xx server error
|
||||||
a-server-operator-has-received-a-legal-demand-to-deny-access-to-a-resource-or-to-a-set-of-resources-that-includes-the-requested-resource: >-
|
a-server-operator-has-received-a-legal-demand-to-deny-access-to-a-resource-or-to-a-set-of-resources-that-includes-the-requested-resource:
|
||||||
|
>-
|
||||||
A server operator has received a legal demand to deny access to a
|
A server operator has received a legal demand to deny access to a
|
||||||
resource or to a set of resources that includes the requested
|
resource or to a set of resources that includes the requested
|
||||||
resource.
|
resource.
|
||||||
unavailable-for-legal-reasons: Unavailable For Legal Reasons
|
unavailable-for-legal-reasons: Unavailable For Legal Reasons
|
||||||
the-server-is-unwilling-to-process-the-request-because-either-an-individual-header-field-or-all-the-header-fields-collectively-are-too-large: >-
|
the-server-is-unwilling-to-process-the-request-because-either-an-individual-header-field-or-all-the-header-fields-collectively-are-too-large:
|
||||||
|
>-
|
||||||
The server is unwilling to process the request because either an
|
The server is unwilling to process the request because either an
|
||||||
individual header field, or all the header fields collectively, are
|
individual header field, or all the header fields collectively, are
|
||||||
too large.
|
too large.
|
||||||
@@ -6685,7 +6706,8 @@ tools:
|
|||||||
Indicates that the resource requested is no longer available and will
|
Indicates that the resource requested is no longer available and will
|
||||||
not be available again.
|
not be available again.
|
||||||
gone: Gone
|
gone: Gone
|
||||||
indicates-that-the-request-could-not-be-processed-because-of-conflict-in-the-request-such-as-an-edit-conflict: >-
|
indicates-that-the-request-could-not-be-processed-because-of-conflict-in-the-request-such-as-an-edit-conflict:
|
||||||
|
>-
|
||||||
Indicates that the request could not be processed because of conflict
|
Indicates that the request could not be processed because of conflict
|
||||||
in the request, such as an edit conflict.
|
in the request, such as an edit conflict.
|
||||||
conflict: Conflict
|
conflict: Conflict
|
||||||
@@ -6693,7 +6715,8 @@ tools:
|
|||||||
request-timeout: Request Timeout
|
request-timeout: Request Timeout
|
||||||
the-client-must-first-authenticate-itself-with-the-proxy: The client must first authenticate itself with the proxy.
|
the-client-must-first-authenticate-itself-with-the-proxy: The client must first authenticate itself with the proxy.
|
||||||
proxy-authentication-required: Proxy Authentication Required
|
proxy-authentication-required: Proxy Authentication Required
|
||||||
the-requested-resource-is-capable-of-generating-only-content-not-acceptable-according-to-the-accept-headers-sent-in-the-request: >-
|
the-requested-resource-is-capable-of-generating-only-content-not-acceptable-according-to-the-accept-headers-sent-in-the-request:
|
||||||
|
>-
|
||||||
The requested resource is capable of generating only content not
|
The requested resource is capable of generating only content not
|
||||||
acceptable according to the Accept headers sent in the request.
|
acceptable according to the Accept headers sent in the request.
|
||||||
not-acceptable: Not Acceptable
|
not-acceptable: Not Acceptable
|
||||||
@@ -6702,16 +6725,19 @@ tools:
|
|||||||
the-requested-resource-could-not-be-found-but-may-be-available-in-the-future: >-
|
the-requested-resource-could-not-be-found-but-may-be-available-in-the-future: >-
|
||||||
The requested resource could not be found but may be available in the
|
The requested resource could not be found but may be available in the
|
||||||
future.
|
future.
|
||||||
the-request-was-valid-but-the-server-is-refusing-action-the-user-might-not-have-the-necessary-permissions-for-a-resource: >-
|
the-request-was-valid-but-the-server-is-refusing-action-the-user-might-not-have-the-necessary-permissions-for-a-resource:
|
||||||
|
>-
|
||||||
The request was valid, but the server is refusing action. The user
|
The request was valid, but the server is refusing action. The user
|
||||||
might not have the necessary permissions for a resource.
|
might not have the necessary permissions for a resource.
|
||||||
forbidden: Forbidden
|
forbidden: Forbidden
|
||||||
reserved-for-future-use-the-original-intention-was-that-this-code-might-be-used-as-part-of-some-form-of-digital-cash-or-micropayment-scheme: >-
|
reserved-for-future-use-the-original-intention-was-that-this-code-might-be-used-as-part-of-some-form-of-digital-cash-or-micropayment-scheme:
|
||||||
|
>-
|
||||||
Reserved for future use. The original intention was that this code
|
Reserved for future use. The original intention was that this code
|
||||||
might be used as part of some form of digital cash or micropayment
|
might be used as part of some form of digital cash or micropayment
|
||||||
scheme.
|
scheme.
|
||||||
payment-required: Payment Required
|
payment-required: Payment Required
|
||||||
similar-to-403-forbidden-but-specifically-for-use-when-authentication-is-required-and-has-failed-or-has-not-yet-been-provided: >-
|
similar-to-403-forbidden-but-specifically-for-use-when-authentication-is-required-and-has-failed-or-has-not-yet-been-provided:
|
||||||
|
>-
|
||||||
Similar to 403 Forbidden, but specifically for use when authentication
|
Similar to 403 Forbidden, but specifically for use when authentication
|
||||||
is required and has failed or has not yet been provided.
|
is required and has failed or has not yet been provided.
|
||||||
unauthorized: Unauthorized
|
unauthorized: Unauthorized
|
||||||
@@ -6724,7 +6750,8 @@ tools:
|
|||||||
The request and all future requests should be repeated using another
|
The request and all future requests should be repeated using another
|
||||||
URI.
|
URI.
|
||||||
permanent-redirect: Permanent Redirect
|
permanent-redirect: Permanent Redirect
|
||||||
in-this-case-the-request-should-be-repeated-with-another-uri-however-future-requests-should-still-use-the-original-uri: >-
|
in-this-case-the-request-should-be-repeated-with-another-uri-however-future-requests-should-still-use-the-original-uri:
|
||||||
|
>-
|
||||||
In this case, the request should be repeated with another URI;
|
In this case, the request should be repeated with another URI;
|
||||||
however, future requests should still use the original URI.
|
however, future requests should still use the original URI.
|
||||||
temporary-redirect: Temporary Redirect
|
temporary-redirect: Temporary Redirect
|
||||||
@@ -7314,7 +7341,8 @@ tools:
|
|||||||
label-failure-probability: 'Failure Probability:'
|
label-failure-probability: 'Failure Probability:'
|
||||||
tag-key-terms-explained: 🧠 Key Terms Explained
|
tag-key-terms-explained: 🧠 Key Terms Explained
|
||||||
tag-raid-level: RAID Level
|
tag-raid-level: RAID Level
|
||||||
tag-raid-redundant-array-of-independent-disks-is-a-method-of-combining-multiple-physical-drives-into-one-logical-unit-to-improve-performance-redundancy-or-both: >-
|
tag-raid-redundant-array-of-independent-disks-is-a-method-of-combining-multiple-physical-drives-into-one-logical-unit-to-improve-performance-redundancy-or-both:
|
||||||
|
>-
|
||||||
RAID (Redundant Array of Independent Disks) is a method of combining
|
RAID (Redundant Array of Independent Disks) is a method of combining
|
||||||
multiple physical drives into one logical unit to improve performance,
|
multiple physical drives into one logical unit to improve performance,
|
||||||
redundancy, or both.
|
redundancy, or both.
|
||||||
@@ -7344,34 +7372,41 @@ tools:
|
|||||||
Stripe of RAID 5 arrays. Combines performance of RAID 0 with redundancy
|
Stripe of RAID 5 arrays. Combines performance of RAID 0 with redundancy
|
||||||
of RAID 5.
|
of RAID 5.
|
||||||
tag-️-mtbf-mean-time-between-failures: ⏱️ MTBF (Mean Time Between Failures)
|
tag-️-mtbf-mean-time-between-failures: ⏱️ MTBF (Mean Time Between Failures)
|
||||||
tag-the-average-time-in-hours-a-drive-is-expected-to-operate-before-failing-higher-mtbf-means-more-reliable-hardware: >-
|
tag-the-average-time-in-hours-a-drive-is-expected-to-operate-before-failing-higher-mtbf-means-more-reliable-hardware:
|
||||||
|
>-
|
||||||
The average time (in hours) a drive is expected to operate before
|
The average time (in hours) a drive is expected to operate before
|
||||||
failing. Higher MTBF means more reliable hardware.
|
failing. Higher MTBF means more reliable hardware.
|
||||||
tag-rebuild-time: 🔁 Rebuild Time
|
tag-rebuild-time: 🔁 Rebuild Time
|
||||||
tag-the-time-required-to-reconstruct-data-on-a-replacement-drive-after-a-failure-longer-rebuild-times-increase-the-risk-of-a-second-failure-during-recovery: >-
|
tag-the-time-required-to-reconstruct-data-on-a-replacement-drive-after-a-failure-longer-rebuild-times-increase-the-risk-of-a-second-failure-during-recovery:
|
||||||
|
>-
|
||||||
The time required to reconstruct data on a replacement drive after a
|
The time required to reconstruct data on a replacement drive after a
|
||||||
failure. Longer rebuild times increase the risk of a second failure
|
failure. Longer rebuild times increase the risk of a second failure
|
||||||
during recovery.
|
during recovery.
|
||||||
tag-mttdl-mean-time-to-data-loss: 📉 MTTDL (Mean Time To Data Loss)
|
tag-mttdl-mean-time-to-data-loss: 📉 MTTDL (Mean Time To Data Loss)
|
||||||
tag-a-statistical-estimate-of-how-long-a-raid-system-can-operate-before-data-loss-occurs-it-considers-drive-failures-rebuild-time-and-raid-redundancy-higher-mttdl-means-a-safer-system: >-
|
tag-a-statistical-estimate-of-how-long-a-raid-system-can-operate-before-data-loss-occurs-it-considers-drive-failures-rebuild-time-and-raid-redundancy-higher-mttdl-means-a-safer-system:
|
||||||
|
>-
|
||||||
A statistical estimate of how long a RAID system can operate before data
|
A statistical estimate of how long a RAID system can operate before data
|
||||||
loss occurs. It considers drive failures, rebuild time, and RAID
|
loss occurs. It considers drive failures, rebuild time, and RAID
|
||||||
redundancy. Higher MTTDL means a safer system.
|
redundancy. Higher MTTDL means a safer system.
|
||||||
tag-bit-error-rate-ber: 🧮 Bit Error Rate (BER)
|
tag-bit-error-rate-ber: 🧮 Bit Error Rate (BER)
|
||||||
tag-the-probability-that-a-bit-read-from-a-disk-will-be-incorrect-due-to-hardware-limitations-even-tiny-bers-like-1-in-a-trillion-can-cause-issues-during-rebuilds-especially-with-large-drives: >-
|
tag-the-probability-that-a-bit-read-from-a-disk-will-be-incorrect-due-to-hardware-limitations-even-tiny-bers-like-1-in-a-trillion-can-cause-issues-during-rebuilds-especially-with-large-drives:
|
||||||
|
>-
|
||||||
The probability that a bit read from a disk will be incorrect due to
|
The probability that a bit read from a disk will be incorrect due to
|
||||||
hardware limitations. Even tiny BERs (like 1 in a trillion) can cause
|
hardware limitations. Even tiny BERs (like 1 in a trillion) can cause
|
||||||
issues during rebuilds, especially with large drives.
|
issues during rebuilds, especially with large drives.
|
||||||
tag-unrecoverable-read-error-ure: 🧠 Unrecoverable Read Error (URE)
|
tag-unrecoverable-read-error-ure: 🧠 Unrecoverable Read Error (URE)
|
||||||
tag-occurs-when-a-drive-fails-to-read-a-sector-during-rebuild-ber-contributes-to-ure-risk-which-can-compromise-raid-recovery: >-
|
tag-occurs-when-a-drive-fails-to-read-a-sector-during-rebuild-ber-contributes-to-ure-risk-which-can-compromise-raid-recovery:
|
||||||
|
>-
|
||||||
Occurs when a drive fails to read a sector during rebuild. BER
|
Occurs when a drive fails to read a sector during rebuild. BER
|
||||||
contributes to URE risk, which can compromise RAID recovery.
|
contributes to URE risk, which can compromise RAID recovery.
|
||||||
tag-drive-capacity-tb: 📦 Drive Capacity (TB)
|
tag-drive-capacity-tb: 📦 Drive Capacity (TB)
|
||||||
tag-total-storage-per-drive-larger-drives-take-longer-to-rebuild-and-are-more-susceptible-to-ber-related-errors: >-
|
tag-total-storage-per-drive-larger-drives-take-longer-to-rebuild-and-are-more-susceptible-to-ber-related-errors:
|
||||||
|
>-
|
||||||
Total storage per drive. Larger drives take longer to rebuild and are
|
Total storage per drive. Larger drives take longer to rebuild and are
|
||||||
more susceptible to BER-related errors.
|
more susceptible to BER-related errors.
|
||||||
tag-failure-probability: 📈 Failure Probability
|
tag-failure-probability: 📈 Failure Probability
|
||||||
tag-the-chance-that-the-raid-system-will-experience-data-loss-over-a-given-time-period-e-g-5-years-calculated-using-mttdl-and-exponential-failure-models: >-
|
tag-the-chance-that-the-raid-system-will-experience-data-loss-over-a-given-time-period-e-g-5-years-calculated-using-mttdl-and-exponential-failure-models:
|
||||||
|
>-
|
||||||
The chance that the RAID system will experience data loss over a given
|
The chance that the RAID system will experience data loss over a given
|
||||||
time period (e.g., 5 years). Calculated using MTTDL and exponential
|
time period (e.g., 5 years). Calculated using MTTDL and exponential
|
||||||
failure models.
|
failure models.
|
||||||
@@ -7729,7 +7764,8 @@ tools:
|
|||||||
tag-mirrors-stripes: Mirrors/Stripes
|
tag-mirrors-stripes: Mirrors/Stripes
|
||||||
tag-reset: Reset
|
tag-reset: Reset
|
||||||
tag-see-zpool-openzfs-cheatsheet: See Zpool/OpenZFS Cheatsheet
|
tag-see-zpool-openzfs-cheatsheet: See Zpool/OpenZFS Cheatsheet
|
||||||
tag-click-on-the-section-titles-to-expand-collapse-and-view-calculated-data-hovering-over-a-table-cell-loads-the-relevant-data-into-the-calculation-values-section-below-you-can-click-table-cells-to-freeze-or-unfreeze-those-values: >-
|
tag-click-on-the-section-titles-to-expand-collapse-and-view-calculated-data-hovering-over-a-table-cell-loads-the-relevant-data-into-the-calculation-values-section-below-you-can-click-table-cells-to-freeze-or-unfreeze-those-values:
|
||||||
|
>-
|
||||||
Click on the section titles to expand/collapse and view calculated data.
|
Click on the section titles to expand/collapse and view calculated data.
|
||||||
Hovering over a table cell loads the relevant data into the Calculation
|
Hovering over a table cell loads the relevant data into the Calculation
|
||||||
Values section below. You can click table cells to freeze or unfreeze
|
Values section below. You can click table cells to freeze or unfreeze
|
||||||
@@ -10292,6 +10328,78 @@ tools:
|
|||||||
Test your speakers and headphones by playing test sounds. Adjust volume
|
Test your speakers and headphones by playing test sounds. Adjust volume
|
||||||
and check for audio clarity.
|
and check for audio clarity.
|
||||||
externalAccess: 'null'
|
externalAccess: 'null'
|
||||||
|
paste-image:
|
||||||
|
texts:
|
||||||
|
copy-image: Copy image
|
||||||
|
copy-as-base64: Copy as base64
|
||||||
|
getoutputextension-image: .{0}
|
||||||
|
your-browser-cannot-encode-outputformats-image-outputformat-label-the-image-downloads-as-gettypelabel-image-output-type: Your browser cannot encode {0}. The image downloads as {1}.
|
||||||
|
formatsizedelta-originalsize-image-source-size-outputsize-image-output-size: ({0})
|
||||||
|
output-gettypelabel-image-output-type-formatbytes-image-output-size: 'Output: {0}, {1}'
|
||||||
|
original-gettypelabel-image-source-type-formatbytes-image-source-size: 'Original: {0}, {1}'
|
||||||
|
image-width-image-height-px: '{0} × {1} px'
|
||||||
|
clear-all: Clear all
|
||||||
|
images-length-images-length-1-image-images-pasted-in-this-session: '{0} {1} pasted in this session'
|
||||||
|
quality: '{0}%'
|
||||||
|
paste-from-clipboard: Paste from clipboard
|
||||||
|
the-image-stays-in-your-browser-nothing-is-uploaded: The image stays in your browser. Nothing is uploaded.
|
||||||
|
anywhere-on-this-page-to-paste-an-image: anywhere on this page to paste an image.
|
||||||
|
press: Press
|
||||||
|
the-browser-could-not-copy-the-base64-data-url-to-the-clipboard: The browser could not copy the base64 data URL to the clipboard.
|
||||||
|
base64-data-url-copied-to-the-clipboard: Base64 data URL copied to the clipboard
|
||||||
|
the-browser-could-not-copy-the-image-to-the-clipboard: The browser could not copy the image to the clipboard.
|
||||||
|
image-copied-to-the-clipboard: Image copied to the clipboard
|
||||||
|
the-browser-could-not-read-the-clipboard: The browser could not read the clipboard.
|
||||||
|
the-browser-blocked-clipboard-access-allow-it-in-the-site-settings-or-press-pasteshortcut: >-
|
||||||
|
The browser blocked clipboard access. Allow it in the site settings, or
|
||||||
|
press {0}.
|
||||||
|
your-browser-cannot-read-images-from-the-clipboard-with-a-button-press-pasteshortcut-instead: >-
|
||||||
|
Your browser cannot read images from the clipboard with a button. Press
|
||||||
|
{0} instead.
|
||||||
|
the-browser-could-not-read-the-pasted-image: The browser could not read the pasted image.
|
||||||
|
the-browser-could-not-convert-the-image: The browser could not convert the image.
|
||||||
|
the-clipboard-has-no-image-copy-an-image-then-try-again: The clipboard has no image. Copy an image, then try again.
|
||||||
|
ctrl-v: Ctrl + V
|
||||||
|
v: ⌘ + V
|
||||||
|
whitespace-cleaner:
|
||||||
|
options:
|
||||||
|
texts:
|
||||||
|
convert-crlf-lf: Convert CRLF → LF
|
||||||
|
lf-endings: LF endings
|
||||||
|
left-trim-lines-and-rejoin-paragraphs-for-reddit-discord-slack: Left-trim lines and rejoin paragraphs for Reddit, Discord, Slack
|
||||||
|
markdown-reddit: Markdown / Reddit
|
||||||
|
join-soft-wrapped-paragraphs: Join soft-wrapped paragraphs
|
||||||
|
smart-unwrap: Smart unwrap
|
||||||
|
strip-from-patches: Strip + - {'@'}{'@'} from patches
|
||||||
|
diff-markers: Diff markers
|
||||||
|
remove-common-leading-indent: Remove common leading indent
|
||||||
|
indent: Indent
|
||||||
|
collapse-2-blank-lines-into-1: Collapse 2+ blank lines into 1
|
||||||
|
blank-lines: Blank lines
|
||||||
|
remove-end-of-line-whitespace: Remove end-of-line whitespace
|
||||||
|
trailing-space: Trailing space
|
||||||
|
strip-prefixes: Strip ●, ○, ⏺ prefixes
|
||||||
|
bullet-markers: Bullet markers
|
||||||
|
remove-characters: Remove ─ │ └ ┐ characters
|
||||||
|
box-drawing: Box drawing
|
||||||
|
strip-color-escape-sequences: Strip color escape sequences
|
||||||
|
ansi-codes: ANSI codes
|
||||||
|
strip-1-2-1-t-prefixes: Strip 1│, 2│, 1\\t prefixes
|
||||||
|
line-numbers: Line numbers
|
||||||
|
texts:
|
||||||
|
cleaning-options: Cleaning options
|
||||||
|
ctrl-a-ctrl-c: ⌘/Ctrl+A · Ctrl+C
|
||||||
|
your-cleaned-output-will-appear-here: Your cleaned output will appear here.
|
||||||
|
paste-fragmented-claude-code-output-here: Paste fragmented Claude Code output here…
|
||||||
|
sample: Sample
|
||||||
|
paste: Paste
|
||||||
|
copy-failed-the-output-is-selected-press-ctrl-c-to-copy-it: Copy failed. The output is selected. Press Ctrl+C to copy it.
|
||||||
|
copied-to-the-clipboard: Copied to the clipboard.
|
||||||
|
the-clipboard-api-is-unavailable: The Clipboard API is unavailable.
|
||||||
|
copy-failed: Copy failed
|
||||||
|
copied: Copied ✓
|
||||||
|
stats-value-outputlines-lines-stats-value-outputchars-chars-stats-value-savedpercent: '{0} lines · {1} chars · −{2}%'
|
||||||
|
stats-value-inputlines-lines-stats-value-inputchars-chars: '{0} lines · {1} chars'
|
||||||
analogSignalConverter:
|
analogSignalConverter:
|
||||||
texts:
|
texts:
|
||||||
title-input: Input
|
title-input: Input
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import { defineTool } from '../tool';
|
||||||
|
|
||||||
|
export const tool = defineTool({
|
||||||
|
name: 'Whitespace Cleaner',
|
||||||
|
path: '/whitespace-cleaner',
|
||||||
|
description:
|
||||||
|
'Clean terminal and Claude Code output: strip line numbers, ANSI codes, box drawing, bullet markers, diff markers, and extra whitespace.',
|
||||||
|
keywords: [
|
||||||
|
'whitespace',
|
||||||
|
'cleaner',
|
||||||
|
'clean',
|
||||||
|
'claude',
|
||||||
|
'terminal',
|
||||||
|
'ansi',
|
||||||
|
'indent',
|
||||||
|
'trailing',
|
||||||
|
'line',
|
||||||
|
'numbers',
|
||||||
|
'box',
|
||||||
|
'drawing',
|
||||||
|
'diff',
|
||||||
|
'unwrap',
|
||||||
|
'markdown',
|
||||||
|
],
|
||||||
|
component: () => import('./whitespace-cleaner.vue'),
|
||||||
|
icon: defineAsyncComponent(() => import('@vicons/tabler/es/ClearFormatting')),
|
||||||
|
createdAt: new Date('2026-11-15'),
|
||||||
|
category: 'Text',
|
||||||
|
});
|
||||||
@@ -0,0 +1,222 @@
|
|||||||
|
import { type Page, expect, test } from '@playwright/test';
|
||||||
|
|
||||||
|
const SAMPLE_OUTPUT_FIRST_LINE = 'function greetUser(name: string) {';
|
||||||
|
|
||||||
|
function mockClipboard(page: Page, { fail }: { fail: boolean }) {
|
||||||
|
return page.addInitScript((shouldFail) => {
|
||||||
|
Object.defineProperty(navigator, 'clipboard', {
|
||||||
|
configurable: true,
|
||||||
|
value: {
|
||||||
|
writeText: async (text: string) => {
|
||||||
|
if (shouldFail) {
|
||||||
|
throw new DOMException('Write permission denied.', 'NotAllowedError');
|
||||||
|
}
|
||||||
|
(window as unknown as { copiedText: string }).copiedText = text;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}, fail);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getOutputSelection(page: Page) {
|
||||||
|
return page.getByTestId('output').evaluate((element: HTMLTextAreaElement) => ({
|
||||||
|
start: element.selectionStart,
|
||||||
|
end: element.selectionEnd,
|
||||||
|
length: element.value.length,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
test.describe('Tool - Whitespace cleaner', () => {
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await page.goto('/whitespace-cleaner');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Has correct title', async ({ page }) => {
|
||||||
|
await expect(page).toHaveTitle('Whitespace cleaner - Toolbox');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('U1 updates the output on input with no button press', async ({ page }) => {
|
||||||
|
await page.getByTestId('input').fill(' 12 │ a\n 13 │ b ');
|
||||||
|
|
||||||
|
await expect(page.getByTestId('output')).toHaveValue('a\nb');
|
||||||
|
await expect(page.getByTestId('output-badge')).toHaveText('2 lines · 3 chars · −85%');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('U2 loads the sample and clears the input', async ({ page }) => {
|
||||||
|
const clearButton = page.getByTestId('clear');
|
||||||
|
await expect(clearButton).toHaveAttribute('aria-disabled', 'true');
|
||||||
|
await expect(page.getByTestId('input-badge')).toHaveText('input');
|
||||||
|
|
||||||
|
await page.getByTestId('sample').click();
|
||||||
|
await expect(page.getByTestId('input')).toHaveValue(/● {2}function greetUser/);
|
||||||
|
await expect(page.getByTestId('output')).toHaveValue(
|
||||||
|
new RegExp(`^${SAMPLE_OUTPUT_FIRST_LINE.replace(/[()]/g, '\\$&')}`),
|
||||||
|
);
|
||||||
|
await expect(page.getByTestId('input-badge')).toHaveText(/^8 lines · \d+ chars$/);
|
||||||
|
await expect(clearButton).toHaveAttribute('aria-disabled', 'false');
|
||||||
|
|
||||||
|
await clearButton.click();
|
||||||
|
await expect(page.getByTestId('input')).toHaveValue('');
|
||||||
|
await expect(page.getByTestId('output')).toHaveValue('');
|
||||||
|
await expect(clearButton).toHaveAttribute('aria-disabled', 'true');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('U3 shows "Copied ✓" for 1.5 s after a successful copy', async ({ page }) => {
|
||||||
|
await mockClipboard(page, { fail: false });
|
||||||
|
await page.reload();
|
||||||
|
|
||||||
|
const copyButton = page.getByTestId('copy');
|
||||||
|
await expect(copyButton).toHaveAttribute('aria-disabled', 'true');
|
||||||
|
|
||||||
|
await page.getByTestId('sample').click();
|
||||||
|
await expect(copyButton).toHaveAttribute('aria-disabled', 'false');
|
||||||
|
await copyButton.click();
|
||||||
|
|
||||||
|
await expect(copyButton).toHaveText('Copied ✓');
|
||||||
|
await expect(page.getByTestId('copy-status')).toHaveText('Copied to the clipboard.');
|
||||||
|
expect(await page.evaluate(() => (window as unknown as { copiedText: string }).copiedText)).toMatch(
|
||||||
|
new RegExp(`^${SAMPLE_OUTPUT_FIRST_LINE.replace(/[()]/g, '\\$&')}`),
|
||||||
|
);
|
||||||
|
await expect(copyButton).toHaveText('Copy', { timeout: 3000 });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('U3 shows an error state and selects the output when the clipboard is denied', async ({ page }) => {
|
||||||
|
await mockClipboard(page, { fail: true });
|
||||||
|
await page.reload();
|
||||||
|
|
||||||
|
await page.getByTestId('sample').click();
|
||||||
|
await page.getByTestId('copy').click();
|
||||||
|
|
||||||
|
await expect(page.getByTestId('copy')).toHaveText('Copy failed');
|
||||||
|
await expect(page.getByTestId('copy-status')).toHaveText(/Copy failed/);
|
||||||
|
await expect(page.getByTestId('output')).toBeFocused();
|
||||||
|
|
||||||
|
const selection = await getOutputSelection(page);
|
||||||
|
expect(selection).toEqual({ start: 0, end: selection.length, length: selection.length });
|
||||||
|
expect(selection.length).toBeGreaterThan(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('U4 selects all output on focus and on click with no selection', async ({ page }) => {
|
||||||
|
await page.getByTestId('sample').click();
|
||||||
|
const output = page.getByTestId('output');
|
||||||
|
await expect(output).not.toHaveValue('');
|
||||||
|
|
||||||
|
await output.focus();
|
||||||
|
let selection = await getOutputSelection(page);
|
||||||
|
expect(selection).toEqual({ start: 0, end: selection.length, length: selection.length });
|
||||||
|
|
||||||
|
await output.evaluate((element: HTMLTextAreaElement) => element.setSelectionRange(3, 3));
|
||||||
|
await output.click();
|
||||||
|
selection = await getOutputSelection(page);
|
||||||
|
expect(selection).toEqual({ start: 0, end: selection.length, length: selection.length });
|
||||||
|
|
||||||
|
await output.evaluate((element: HTMLTextAreaElement) => element.setSelectionRange(3, 3));
|
||||||
|
await output.blur();
|
||||||
|
await output.click();
|
||||||
|
selection = await getOutputSelection(page);
|
||||||
|
expect(selection).toEqual({ start: 0, end: selection.length, length: selection.length });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('U4 keeps a partial drag selection', async ({ page }) => {
|
||||||
|
await page.getByTestId('sample').click();
|
||||||
|
const output = page.getByTestId('output');
|
||||||
|
await expect(output).not.toHaveValue('');
|
||||||
|
await expect(output).not.toBeFocused();
|
||||||
|
|
||||||
|
const box = await output.boundingBox();
|
||||||
|
if (!box) {
|
||||||
|
throw new Error('The output has no bounding box.');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function dragAcrossFirstLine() {
|
||||||
|
await page.mouse.move(box!.x + 20, box!.y + 12);
|
||||||
|
await page.mouse.down();
|
||||||
|
await page.mouse.move(box!.x + 80, box!.y + 12, { steps: 5 });
|
||||||
|
await page.mouse.up();
|
||||||
|
|
||||||
|
const selection = await getOutputSelection(page);
|
||||||
|
expect(selection.end - selection.start).toBeGreaterThan(0);
|
||||||
|
expect(selection.end - selection.start).toBeLessThan(selection.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
await dragAcrossFirstLine();
|
||||||
|
|
||||||
|
// A click selects all. A drag that starts inside that selection still selects part of the output.
|
||||||
|
await output.click();
|
||||||
|
const selection = await getOutputSelection(page);
|
||||||
|
expect(selection).toEqual({ start: 0, end: selection.length, length: selection.length });
|
||||||
|
|
||||||
|
await dragAcrossFirstLine();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('U4 keeps the scroll position when a click selects all', async ({ page }) => {
|
||||||
|
await page.getByTestId('input').fill(Array.from({ length: 200 }, (_, index) => `line ${index}`).join('\n'));
|
||||||
|
const output = page.getByTestId('output');
|
||||||
|
await expect(output).toHaveValue(/line 199$/);
|
||||||
|
|
||||||
|
// Waiting two frames lets a scroll that the browser applies after a selection change take effect.
|
||||||
|
const waitForFrames = () =>
|
||||||
|
page.evaluate(() => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve))));
|
||||||
|
|
||||||
|
await output.click();
|
||||||
|
await waitForFrames();
|
||||||
|
await output.evaluate((element: HTMLTextAreaElement) => {
|
||||||
|
element.scrollTop = 1000;
|
||||||
|
});
|
||||||
|
|
||||||
|
// The press collapses the full selection, and the click selects all again.
|
||||||
|
const box = await output.boundingBox();
|
||||||
|
await page.mouse.move(box!.x + 20, box!.y + 40);
|
||||||
|
await page.mouse.down();
|
||||||
|
await page.mouse.up();
|
||||||
|
await waitForFrames();
|
||||||
|
|
||||||
|
const selection = await getOutputSelection(page);
|
||||||
|
expect(selection).toEqual({ start: 0, end: selection.length, length: selection.length });
|
||||||
|
expect(await output.evaluate((element: HTMLTextAreaElement) => element.scrollTop)).toBe(1000);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('U5 shows the hint only while the output has content', async ({ page }) => {
|
||||||
|
await expect(page.getByTestId('output-hint')).toHaveCount(0);
|
||||||
|
|
||||||
|
await page.getByTestId('sample').click();
|
||||||
|
await expect(page.getByTestId('output-hint')).toHaveText('⌘/Ctrl+A · Ctrl+C');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('U6 toggles an option chip', async ({ page }) => {
|
||||||
|
await page.getByTestId('input').fill('● foo');
|
||||||
|
await expect(page.getByTestId('output')).toHaveValue('foo');
|
||||||
|
|
||||||
|
const chip = page.getByTestId('option-stripBulletMarkers');
|
||||||
|
await expect(chip).toHaveAttribute('aria-pressed', 'true');
|
||||||
|
|
||||||
|
await chip.click();
|
||||||
|
await expect(chip).toHaveAttribute('aria-pressed', 'false');
|
||||||
|
await expect(page.getByTestId('output')).toHaveValue('● foo');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('U7 stacks the panes with no horizontal scroll on a narrow viewport', async ({ page }) => {
|
||||||
|
await page.setViewportSize({ width: 375, height: 800 });
|
||||||
|
await page.getByTestId('sample').click();
|
||||||
|
|
||||||
|
const inputBox = await page.getByTestId('input').boundingBox();
|
||||||
|
const outputBox = await page.getByTestId('output').boundingBox();
|
||||||
|
expect(inputBox && outputBox && outputBox.y > inputBox.y + inputBox.height).toBe(true);
|
||||||
|
|
||||||
|
const hasHorizontalScroll = await page.evaluate(
|
||||||
|
() => document.documentElement.scrollWidth > document.documentElement.clientWidth,
|
||||||
|
);
|
||||||
|
expect(hasHorizontalScroll).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('OS4 keeps the options and drops the input across reloads', async ({ page }) => {
|
||||||
|
await page.getByTestId('input').fill('some text');
|
||||||
|
await page.getByTestId('option-markdownMode').click();
|
||||||
|
await expect(page.getByTestId('option-markdownMode')).toHaveAttribute('aria-pressed', 'true');
|
||||||
|
|
||||||
|
await page.reload();
|
||||||
|
|
||||||
|
await expect(page.getByTestId('option-markdownMode')).toHaveAttribute('aria-pressed', 'true');
|
||||||
|
await expect(page.getByTestId('input')).toHaveValue('');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
import { OPTIONS_STORAGE_KEY, getDefaultOptions, loadOptions, saveOptions } from './whitespace-cleaner.options';
|
||||||
|
|
||||||
|
function createStorage(initial: Record<string, string> = {}) {
|
||||||
|
const values = new Map(Object.entries(initial));
|
||||||
|
|
||||||
|
return {
|
||||||
|
getItem: (key: string) => values.get(key) ?? null,
|
||||||
|
setItem: (key: string, value: string) => {
|
||||||
|
values.set(key, value);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('whitespace-cleaner options', () => {
|
||||||
|
it('turns Markdown / Reddit off by default', () => {
|
||||||
|
expect(getDefaultOptions().markdownMode).to.eql(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('OS1 returns the defaults when nothing is saved', () => {
|
||||||
|
expect(loadOptions(createStorage())).to.eql(getDefaultOptions());
|
||||||
|
});
|
||||||
|
|
||||||
|
it('OS2 ignores unknown keys and keeps the default for missing keys', () => {
|
||||||
|
const { stripLineNumbers: _missing, ...saved } = { ...getDefaultOptions(), removeAnsi: false, smartUnwrap: true };
|
||||||
|
const storage = createStorage({ [OPTIONS_STORAGE_KEY]: JSON.stringify({ ...saved, unknownKey: true }) });
|
||||||
|
|
||||||
|
const options = loadOptions(storage);
|
||||||
|
|
||||||
|
expect(options).to.eql({ ...getDefaultOptions(), removeAnsi: false, smartUnwrap: true });
|
||||||
|
expect(options).not.to.have.property('unknownKey');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('OS3 returns the defaults when the storage throws an error', () => {
|
||||||
|
const storage = {
|
||||||
|
getItem: () => {
|
||||||
|
throw new Error('SecurityError');
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(loadOptions(storage)).to.eql(getDefaultOptions());
|
||||||
|
expect(loadOptions(undefined)).to.eql(getDefaultOptions());
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const raw of ['{not json', 'null', '[]', '42', '"text"', '{"removeAnsi":"no"}']) {
|
||||||
|
it(`OS3 returns the defaults when the saved data is invalid: ${raw}`, () => {
|
||||||
|
expect(loadOptions(createStorage({ [OPTIONS_STORAGE_KEY]: raw }))).to.eql(getDefaultOptions());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
it('saves the full options object and loads it back', () => {
|
||||||
|
const storage = createStorage();
|
||||||
|
const options = { ...getDefaultOptions(), markdownMode: true, trimTrailing: false };
|
||||||
|
|
||||||
|
saveOptions(storage, options);
|
||||||
|
|
||||||
|
expect(loadOptions(storage)).to.eql(options);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ignores write errors', () => {
|
||||||
|
const storage = {
|
||||||
|
setItem: () => {
|
||||||
|
throw new Error('QuotaExceededError');
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(() => saveOptions(storage, getDefaultOptions())).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
import type { CleanerOptions } from './whitespace-cleaner.service';
|
||||||
|
|
||||||
|
import { translate as t } from '@/plugins/i18n.plugin';
|
||||||
|
|
||||||
|
export interface OptionDefinition {
|
||||||
|
key: keyof CleanerOptions;
|
||||||
|
label: string;
|
||||||
|
hint: string;
|
||||||
|
defaultValue: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The chips appear in this order. The cleaner core runs its steps in its own fixed order.
|
||||||
|
export const OPTION_DEFINITIONS: readonly OptionDefinition[] = [
|
||||||
|
{
|
||||||
|
key: 'stripLineNumbers',
|
||||||
|
label: t('tools.whitespace-cleaner.options.texts.line-numbers'),
|
||||||
|
hint: t('tools.whitespace-cleaner.options.texts.strip-1-2-1-t-prefixes'),
|
||||||
|
defaultValue: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'removeAnsi',
|
||||||
|
label: t('tools.whitespace-cleaner.options.texts.ansi-codes'),
|
||||||
|
hint: t('tools.whitespace-cleaner.options.texts.strip-color-escape-sequences'),
|
||||||
|
defaultValue: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'stripBoxDrawing',
|
||||||
|
label: t('tools.whitespace-cleaner.options.texts.box-drawing'),
|
||||||
|
hint: t('tools.whitespace-cleaner.options.texts.remove-characters'),
|
||||||
|
defaultValue: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'stripBulletMarkers',
|
||||||
|
label: t('tools.whitespace-cleaner.options.texts.bullet-markers'),
|
||||||
|
hint: t('tools.whitespace-cleaner.options.texts.strip-prefixes'),
|
||||||
|
defaultValue: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'trimTrailing',
|
||||||
|
label: t('tools.whitespace-cleaner.options.texts.trailing-space'),
|
||||||
|
hint: t('tools.whitespace-cleaner.options.texts.remove-end-of-line-whitespace'),
|
||||||
|
defaultValue: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'collapseBlankLines',
|
||||||
|
label: t('tools.whitespace-cleaner.options.texts.blank-lines'),
|
||||||
|
hint: t('tools.whitespace-cleaner.options.texts.collapse-2-blank-lines-into-1'),
|
||||||
|
defaultValue: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'normalizeIndent',
|
||||||
|
label: t('tools.whitespace-cleaner.options.texts.indent'),
|
||||||
|
hint: t('tools.whitespace-cleaner.options.texts.remove-common-leading-indent'),
|
||||||
|
defaultValue: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'removeDiffMarkers',
|
||||||
|
label: t('tools.whitespace-cleaner.options.texts.diff-markers'),
|
||||||
|
hint: t('tools.whitespace-cleaner.options.texts.strip-from-patches'),
|
||||||
|
defaultValue: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'smartUnwrap',
|
||||||
|
label: t('tools.whitespace-cleaner.options.texts.smart-unwrap'),
|
||||||
|
hint: t('tools.whitespace-cleaner.options.texts.join-soft-wrapped-paragraphs'),
|
||||||
|
defaultValue: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'markdownMode',
|
||||||
|
label: t('tools.whitespace-cleaner.options.texts.markdown-reddit'),
|
||||||
|
hint: t('tools.whitespace-cleaner.options.texts.left-trim-lines-and-rejoin-paragraphs-for-reddit-discord-slack'),
|
||||||
|
defaultValue: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'unifyLineEndings',
|
||||||
|
label: t('tools.whitespace-cleaner.options.texts.lf-endings'),
|
||||||
|
hint: t('tools.whitespace-cleaner.options.texts.convert-crlf-lf'),
|
||||||
|
defaultValue: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const OPTIONS_STORAGE_KEY = 'whitespace-cleaner.options.v1';
|
||||||
|
|
||||||
|
export function getDefaultOptions(): CleanerOptions {
|
||||||
|
return Object.fromEntries(
|
||||||
|
OPTION_DEFINITIONS.map(({ key, defaultValue }) => [key, defaultValue]),
|
||||||
|
) as unknown as CleanerOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Merges the saved options over the defaults.
|
||||||
|
// Unknown keys and non-boolean values are ignored. Missing keys keep their default.
|
||||||
|
export function loadOptions(storage: Pick<Storage, 'getItem'> | undefined): CleanerOptions {
|
||||||
|
const options = getDefaultOptions();
|
||||||
|
|
||||||
|
try {
|
||||||
|
const raw = storage?.getItem(OPTIONS_STORAGE_KEY);
|
||||||
|
if (!raw) {
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
const saved: unknown = JSON.parse(raw);
|
||||||
|
if (typeof saved !== 'object' || saved === null || Array.isArray(saved)) {
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const { key } of OPTION_DEFINITIONS) {
|
||||||
|
const value = (saved as Record<string, unknown>)[key];
|
||||||
|
if (typeof value === 'boolean') {
|
||||||
|
options[key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return options;
|
||||||
|
} catch {
|
||||||
|
return getDefaultOptions();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function saveOptions(storage: Pick<Storage, 'setItem'> | undefined, options: CleanerOptions): void {
|
||||||
|
try {
|
||||||
|
storage?.setItem(OPTIONS_STORAGE_KEY, JSON.stringify(options));
|
||||||
|
} catch {
|
||||||
|
// A failed write only loses the saved options. The cleaner keeps working.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reading `window.localStorage` throws when the browser blocks site data.
|
||||||
|
export function getBrowserStorage(): Storage | undefined {
|
||||||
|
try {
|
||||||
|
return window.localStorage;
|
||||||
|
} catch {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
export const SAMPLE_INPUT = [
|
||||||
|
' 1\t● function greetUser(name: string) {',
|
||||||
|
// eslint-disable-next-line no-template-curly-in-string -- The sample is TypeScript source text.
|
||||||
|
' 2\t│ console.log(`Hello, ${name}!`);',
|
||||||
|
' 3\t│ }',
|
||||||
|
' 4\t│',
|
||||||
|
' 5\t│ greetUser("world");',
|
||||||
|
'',
|
||||||
|
' ┌─ Done in 0.3s',
|
||||||
|
' └─ 1 file changed',
|
||||||
|
].join('\n');
|
||||||
@@ -0,0 +1,197 @@
|
|||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
import { type CleanerOptions, cleanText, computeStats } from './whitespace-cleaner.service';
|
||||||
|
import { getDefaultOptions } from './whitespace-cleaner.options';
|
||||||
|
import { SAMPLE_INPUT } from './whitespace-cleaner.sample';
|
||||||
|
|
||||||
|
const ALL_OFF: CleanerOptions = {
|
||||||
|
stripLineNumbers: false,
|
||||||
|
removeAnsi: false,
|
||||||
|
stripBoxDrawing: false,
|
||||||
|
stripBulletMarkers: false,
|
||||||
|
trimTrailing: false,
|
||||||
|
collapseBlankLines: false,
|
||||||
|
normalizeIndent: false,
|
||||||
|
removeDiffMarkers: false,
|
||||||
|
smartUnwrap: false,
|
||||||
|
markdownMode: false,
|
||||||
|
unifyLineEndings: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
function isolated(...keys: (keyof CleanerOptions)[]): CleanerOptions {
|
||||||
|
return { ...ALL_OFF, ...Object.fromEntries(keys.map((key) => [key, true])) };
|
||||||
|
}
|
||||||
|
|
||||||
|
// `·` marks a space where the count matters.
|
||||||
|
function sp(text: string): string {
|
||||||
|
return text.replace(/·/g, ' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
const PYTHON_FENCE = ['```python', 'def foo():', ' if x:', '', ' return 1', '```'].join('\n');
|
||||||
|
|
||||||
|
describe('whitespace-cleaner', () => {
|
||||||
|
describe('cleanText, isolated options', () => {
|
||||||
|
const cases: { id: string; options: CleanerOptions; input: string; expected: string }[] = [
|
||||||
|
{ id: 'LE1', options: isolated('unifyLineEndings'), input: 'a\r\nb\rc', expected: 'a\nb\nc' },
|
||||||
|
{ id: 'AN1', options: isolated('removeAnsi'), input: '\x1B[31mred\x1B[0m', expected: 'red' },
|
||||||
|
{ id: 'AN2 (defect 6)', options: isolated('removeAnsi'), input: '\x1B[?25lx\x1B[?25h', expected: 'x' },
|
||||||
|
{
|
||||||
|
id: 'AN3 (defect 6)',
|
||||||
|
options: isolated('removeAnsi'),
|
||||||
|
input: '\x1B]8;;https://example.com\x07link\x1B]8;;\x07',
|
||||||
|
expected: 'link',
|
||||||
|
},
|
||||||
|
{ id: 'AN4 (defect 6)', options: isolated('removeAnsi'), input: '\x1B]0;title\x1B\\x', expected: 'x' },
|
||||||
|
{ id: 'AN5 (defect 6)', options: isolated('removeAnsi'), input: '\x1B(Bx', expected: 'x' },
|
||||||
|
{ id: 'AW1', options: ALL_OFF, input: '\n\na\u00A0b\u200Bc\n\n', expected: 'a bc' },
|
||||||
|
{ id: 'LN1', options: isolated('stripLineNumbers'), input: sp('···1\tfoo\n···2\tbar'), expected: 'foo\nbar' },
|
||||||
|
{
|
||||||
|
id: 'LN2 (defect 3)',
|
||||||
|
options: isolated('stripLineNumbers', 'stripBoxDrawing'),
|
||||||
|
input: sp('··12·│·a\n··13·│·b'),
|
||||||
|
expected: 'a\nb',
|
||||||
|
},
|
||||||
|
{ id: 'LN3', options: isolated('stripLineNumbers'), input: sp('·····1→a\n·····2→b'), expected: 'a\nb' },
|
||||||
|
{
|
||||||
|
id: 'LN4',
|
||||||
|
options: isolated('stripLineNumbers'),
|
||||||
|
input: '1\tlong\ncontinued\n2\tnext',
|
||||||
|
expected: 'long\ncontinued\nnext',
|
||||||
|
},
|
||||||
|
{ id: 'LN5', options: isolated('stripLineNumbers'), input: '42\tfoo', expected: '42\tfoo' },
|
||||||
|
{
|
||||||
|
id: 'LN6 (defect 5)',
|
||||||
|
options: isolated('stripLineNumbers'),
|
||||||
|
input: '0: "zero",\n1: "one",',
|
||||||
|
expected: '0: "zero",\n1: "one",',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'LN7 (defect 5)',
|
||||||
|
options: isolated('stripLineNumbers'),
|
||||||
|
input: '10\tfoo\n20\tbar',
|
||||||
|
expected: '10\tfoo\n20\tbar',
|
||||||
|
},
|
||||||
|
{ id: 'LN8', options: isolated('stripLineNumbers'), input: '3\tx\n4\t\n5\ty', expected: 'x\n\ny' },
|
||||||
|
{ id: 'BM1', options: isolated('stripBulletMarkers'), input: sp('●·foo'), expected: sp('··foo') },
|
||||||
|
{ id: 'BM2', options: isolated('stripBulletMarkers'), input: 'a ● b', expected: 'a ● b' },
|
||||||
|
{ id: 'BX1', options: isolated('stripBoxDrawing'), input: 'x\n┌───┐\ny', expected: 'x\n\ny' },
|
||||||
|
{ id: 'BX2', options: isolated('stripBoxDrawing'), input: sp('│··x'), expected: sp('···x') },
|
||||||
|
{
|
||||||
|
id: 'BX3 (defect 4)',
|
||||||
|
options: isolated('stripBoxDrawing'),
|
||||||
|
input: 'print("a → b ■ done")',
|
||||||
|
expected: 'print("a → b ■ done")',
|
||||||
|
},
|
||||||
|
{ id: 'BX4', options: isolated('stripBoxDrawing'), input: sp('│·x·│'), expected: sp('··x') },
|
||||||
|
{
|
||||||
|
id: 'DF1 (defect 9)',
|
||||||
|
options: isolated('removeDiffMarkers'),
|
||||||
|
input: sp('@@ -1,3 +1,3 @@\n·def foo():\n-····return 1\n+····return 2\n·x = 1'),
|
||||||
|
expected: sp('def foo():\n····return 2\nx = 1'),
|
||||||
|
},
|
||||||
|
{ id: 'DF2', options: isolated('removeDiffMarkers'), input: '+a\n-b\n--- c', expected: 'a\nb\n--- c' },
|
||||||
|
{ id: 'TT1', options: isolated('trimTrailing'), input: sp('a··\t\nb'), expected: 'a\nb' },
|
||||||
|
{
|
||||||
|
id: 'IN1',
|
||||||
|
options: isolated('normalizeIndent'),
|
||||||
|
input: sp('····a\n······b\n\n····c'),
|
||||||
|
expected: sp('a\n··b\n\nc'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'IN2 (defect 7)',
|
||||||
|
options: isolated('normalizeIndent'),
|
||||||
|
input: sp('\tfoo\n····bar'),
|
||||||
|
expected: sp('\tfoo\n····bar'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'SU1 (defect 10)',
|
||||||
|
options: isolated('smartUnwrap'),
|
||||||
|
input: 'one two\nthree four\nfive six\nseven',
|
||||||
|
expected: 'one two three four five six seven',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'SU2',
|
||||||
|
options: isolated('smartUnwrap'),
|
||||||
|
input: 'first part\nends here.\nnext',
|
||||||
|
expected: 'first part ends here.\nnext',
|
||||||
|
},
|
||||||
|
{ id: 'SU3', options: isolated('smartUnwrap'), input: 'intro\n- item', expected: 'intro\n- item' },
|
||||||
|
{
|
||||||
|
id: 'SU4',
|
||||||
|
options: isolated('smartUnwrap'),
|
||||||
|
input: '```\nshort\nlines\n```',
|
||||||
|
expected: '```\nshort\nlines\n```',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'MD1',
|
||||||
|
options: isolated('markdownMode'),
|
||||||
|
input: sp('··some wrapped\n··text here'),
|
||||||
|
expected: 'some wrapped text here',
|
||||||
|
},
|
||||||
|
{ id: 'MD2', options: isolated('markdownMode'), input: sp('··- a\n··- b'), expected: '- a\n- b' },
|
||||||
|
{ id: 'MD3 (defect 2)', options: isolated('markdownMode'), input: PYTHON_FENCE, expected: PYTHON_FENCE },
|
||||||
|
{ id: 'CB1', options: isolated('collapseBlankLines'), input: 'a\n\n\n\nb', expected: 'a\n\nb' },
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const { id, options, input, expected } of cases) {
|
||||||
|
it(`Test: ${id}`, () => {
|
||||||
|
expect(cleanText(input, options)).to.eql(expected);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
it('returns any input unchanged when all options are off, apart from the always-on steps', () => {
|
||||||
|
const input = sp('··1\t●·│·foo··\r\n\n\n\x1B[31m+bar\x1B[0m\n@@ -1 +1 @@\n····baz');
|
||||||
|
|
||||||
|
expect(cleanText(input, ALL_OFF)).to.eql(input);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('cleanText, default options', () => {
|
||||||
|
it('G1 cleans the sample', () => {
|
||||||
|
const expected = [
|
||||||
|
'function greetUser(name: string) {',
|
||||||
|
// eslint-disable-next-line no-template-curly-in-string -- The sample is TypeScript source text.
|
||||||
|
' console.log(`Hello, ${name}!`);',
|
||||||
|
'}',
|
||||||
|
'',
|
||||||
|
'greetUser("world");',
|
||||||
|
'',
|
||||||
|
' Done in 0.3s',
|
||||||
|
' 1 file changed',
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
|
expect(cleanText(SAMPLE_INPUT, getDefaultOptions())).to.eql(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('G2 (defect 1) keeps unfenced code on separate lines', () => {
|
||||||
|
const input = sp('def foo():\n····if x:\n········return 1');
|
||||||
|
|
||||||
|
expect(cleanText(input, getDefaultOptions())).to.eql(input);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('G3 strips a bullet marker and the common indent', () => {
|
||||||
|
expect(cleanText(sp('⏺·I fixed the bug.\n··It was in the parser.'), getDefaultOptions())).to.eql(
|
||||||
|
'I fixed the bug.\nIt was in the parser.',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('computeStats', () => {
|
||||||
|
it('ST1 returns zero counts for empty input', () => {
|
||||||
|
expect(computeStats('', '')).to.eql({
|
||||||
|
inputLines: 0,
|
||||||
|
inputChars: 0,
|
||||||
|
outputLines: 0,
|
||||||
|
outputChars: 0,
|
||||||
|
savedPercent: 0,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ST2 computes the saved percentage', () => {
|
||||||
|
expect(computeStats('a'.repeat(100), 'a'.repeat(80)).savedPercent).to.eql(20);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('counts lines', () => {
|
||||||
|
expect(computeStats('a\r\nb\nc', 'a').inputLines).to.eql(3);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,383 @@
|
|||||||
|
export interface CleanerOptions {
|
||||||
|
stripLineNumbers: boolean;
|
||||||
|
removeAnsi: boolean;
|
||||||
|
stripBoxDrawing: boolean;
|
||||||
|
stripBulletMarkers: boolean;
|
||||||
|
trimTrailing: boolean;
|
||||||
|
collapseBlankLines: boolean;
|
||||||
|
normalizeIndent: boolean;
|
||||||
|
removeDiffMarkers: boolean;
|
||||||
|
smartUnwrap: boolean;
|
||||||
|
markdownMode: boolean;
|
||||||
|
unifyLineEndings: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CleanerStats {
|
||||||
|
inputLines: number;
|
||||||
|
inputChars: number;
|
||||||
|
outputLines: number;
|
||||||
|
outputChars: number;
|
||||||
|
savedPercent: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ECMA-48 escape sequences, in this order:
|
||||||
|
// - OSC: ESC ] up to and including BEL or ESC \. The payload stops at the first ESC, so an unterminated OSC cannot scan the rest of the text.
|
||||||
|
// - CSI: ESC [ (or 0x9B), parameter bytes 0x30-0x3F, intermediate bytes 0x20-0x2F, one final byte 0x40-0x7E.
|
||||||
|
// - Other escapes: ESC, intermediate bytes 0x20-0x2F, one final byte 0x30-0x7E.
|
||||||
|
// eslint-disable-next-line no-control-regex
|
||||||
|
const ANSI_PATTERN =
|
||||||
|
// oxlint-disable-next-line no-control-regex
|
||||||
|
/\x1B\][^\x07\x1B]*(?:\x07|\x1B\\)|(?:\x1B\[|\x9B)[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|\x1B[\x20-\x2F]*[\x30-\x7E]/g;
|
||||||
|
|
||||||
|
const LINE_NUMBER_PREFIX = /^[ \t]*(\d{1,5})(?:\t| *[│|→] ?)/;
|
||||||
|
|
||||||
|
export const BULLET_CHARS = new Set(['●', '○', '◐', '◑', '◒', '◓', '◔', '◕', '⏺', '⏵', '▶', '▷', '►']);
|
||||||
|
|
||||||
|
const FENCE_LINE = /^\s*(`{3,}|~{3,})/;
|
||||||
|
const DIFF_HUNK_HEADER = /^@@ .*@@/;
|
||||||
|
const SENTENCE_END = /[.!?:;]$/;
|
||||||
|
const UNWRAP_STOP_START = /^(?:[-*•#]|\d+\.|`{3}|~{3}| {2}|\t)/;
|
||||||
|
const MARKDOWN_BLOCK_LINE = /^\s*(?:[-*+•]\s|\d+[.)]\s|#{1,6}(?:\s|$)|>|\|)/;
|
||||||
|
|
||||||
|
export function cleanText(input: string, options: CleanerOptions): string {
|
||||||
|
let text = input;
|
||||||
|
|
||||||
|
if (options.unifyLineEndings) {
|
||||||
|
text = text.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.removeAnsi) {
|
||||||
|
text = removeAnsiSequences(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
text = text.replace(/\xA0/g, ' ').replace(/\u200B/g, '');
|
||||||
|
|
||||||
|
let lines = text.split('\n');
|
||||||
|
|
||||||
|
if (options.stripLineNumbers) {
|
||||||
|
lines = stripLineNumbers(lines);
|
||||||
|
}
|
||||||
|
if (options.stripBulletMarkers) {
|
||||||
|
lines = lines.map((line) => clearLeadingRegion(line, isBulletChar));
|
||||||
|
}
|
||||||
|
if (options.stripBoxDrawing) {
|
||||||
|
lines = stripFrames(lines);
|
||||||
|
}
|
||||||
|
if (options.removeDiffMarkers) {
|
||||||
|
lines = stripDiffMarkers(lines);
|
||||||
|
}
|
||||||
|
if (options.trimTrailing) {
|
||||||
|
lines = lines.map((line) => line.replace(/[ \t]+$/, ''));
|
||||||
|
}
|
||||||
|
if (options.normalizeIndent) {
|
||||||
|
lines = removeCommonIndent(lines);
|
||||||
|
}
|
||||||
|
if (options.smartUnwrap) {
|
||||||
|
lines = smartUnwrap(lines);
|
||||||
|
}
|
||||||
|
if (options.markdownMode) {
|
||||||
|
lines = markdownReflow(lines);
|
||||||
|
}
|
||||||
|
if (options.collapseBlankLines) {
|
||||||
|
lines = collapseBlankLines(lines);
|
||||||
|
}
|
||||||
|
|
||||||
|
return trimBlankLines(lines).join('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function computeStats(input: string, output: string): CleanerStats {
|
||||||
|
const inputChars = input.length;
|
||||||
|
const outputChars = output.length;
|
||||||
|
|
||||||
|
return {
|
||||||
|
inputLines: countLines(input),
|
||||||
|
inputChars,
|
||||||
|
outputLines: countLines(output),
|
||||||
|
outputChars,
|
||||||
|
savedPercent: inputChars === 0 ? 0 : Math.round(((inputChars - outputChars) / inputChars) * 100),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function removeAnsiSequences(text: string): string {
|
||||||
|
return text.replace(ANSI_PATTERN, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function stripLineNumbers(lines: string[]): string[] {
|
||||||
|
const matches: { index: number; number: number; prefixLength: number }[] = [];
|
||||||
|
|
||||||
|
lines.forEach((line, index) => {
|
||||||
|
const match = LINE_NUMBER_PREFIX.exec(line);
|
||||||
|
if (match) {
|
||||||
|
matches.push({ index, number: Number(match[1]), prefixLength: match[0].length });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = [...lines];
|
||||||
|
|
||||||
|
matches.forEach((match, k) => {
|
||||||
|
const continuesPrevious = matches[k - 1]?.number === match.number - 1;
|
||||||
|
const continuesNext = matches[k + 1]?.number === match.number + 1;
|
||||||
|
|
||||||
|
if (continuesPrevious || continuesNext) {
|
||||||
|
result[match.index] = lines[match.index].slice(match.prefixLength);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The leading region is the longest prefix made only of whitespace and characters accepted by `isMarker`.
|
||||||
|
// Each marker character in that region becomes one space, so code columns keep their alignment.
|
||||||
|
export function clearLeadingRegion(line: string, isMarker: (char: string) => boolean): string {
|
||||||
|
let region = '';
|
||||||
|
let regionLength = 0;
|
||||||
|
|
||||||
|
for (const char of line) {
|
||||||
|
if (isMarker(char)) {
|
||||||
|
region += ' ';
|
||||||
|
} else if (isWhitespace(char)) {
|
||||||
|
region += char;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
regionLength += char.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
return region + line.slice(regionLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function stripFrames(lines: string[]): string[] {
|
||||||
|
return lines.map((line) => {
|
||||||
|
const chars = [...line];
|
||||||
|
const hasFrameChar = chars.some(isFrameChar);
|
||||||
|
|
||||||
|
if (!hasFrameChar) {
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chars.every((char) => isFrameChar(char) || isWhitespace(char))) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
let end = chars.length;
|
||||||
|
while (end > 0 && (isFrameChar(chars[end - 1]) || isWhitespace(chars[end - 1]))) {
|
||||||
|
end--;
|
||||||
|
}
|
||||||
|
const trailingRegion = chars.slice(end);
|
||||||
|
const body = trailingRegion.some(isFrameChar) ? chars.slice(0, end).join('') : line;
|
||||||
|
|
||||||
|
return clearLeadingRegion(body, isFrameChar);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function stripDiffMarkers(lines: string[]): string[] {
|
||||||
|
const result: string[] = [];
|
||||||
|
let inHunk = false;
|
||||||
|
|
||||||
|
for (const line of lines) {
|
||||||
|
if (DIFF_HUNK_HEADER.test(line)) {
|
||||||
|
inHunk = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inHunk) {
|
||||||
|
if (line === '') {
|
||||||
|
result.push(line);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const marker = line[0];
|
||||||
|
if (marker === '+' || marker === ' ') {
|
||||||
|
result.push(line.slice(1));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (marker === '-' || marker === '\\') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
inHunk = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.push(/^[+-](?![+-])/.test(line) ? line.slice(1) : line);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function removeCommonIndent(lines: string[]): string[] {
|
||||||
|
let commonIndent: string | undefined;
|
||||||
|
|
||||||
|
for (const line of lines) {
|
||||||
|
if (isBlank(line)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const indent = /^[ \t]*/.exec(line)?.[0] ?? '';
|
||||||
|
commonIndent = commonIndent === undefined ? indent : commonPrefix(commonIndent, indent);
|
||||||
|
|
||||||
|
if (commonIndent === '') {
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!commonIndent) {
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
const indent = commonIndent;
|
||||||
|
return lines.map((line) => (line.startsWith(indent) ? line.slice(indent.length) : line));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function smartUnwrap(lines: string[]): string[] {
|
||||||
|
const result: string[] = [];
|
||||||
|
const fence = createFenceTracker();
|
||||||
|
let index = 0;
|
||||||
|
|
||||||
|
while (index < lines.length) {
|
||||||
|
const line = lines[index];
|
||||||
|
|
||||||
|
if (fence.update(line)) {
|
||||||
|
result.push(line);
|
||||||
|
index++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let paragraph = line;
|
||||||
|
let lastLine = line;
|
||||||
|
|
||||||
|
while (index + 1 < lines.length && canJoin(lastLine, lines[index + 1])) {
|
||||||
|
const nextLine = lines[index + 1];
|
||||||
|
paragraph = `${paragraph.replace(/\s+$/, '')} ${nextLine.replace(/^\s+/, '')}`;
|
||||||
|
lastLine = nextLine;
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.push(paragraph);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function markdownReflow(lines: string[]): string[] {
|
||||||
|
const result: string[] = [];
|
||||||
|
const fence = createFenceTracker();
|
||||||
|
let paragraph: string[] = [];
|
||||||
|
|
||||||
|
function flushParagraph() {
|
||||||
|
if (paragraph.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (paragraph.some((line) => MARKDOWN_BLOCK_LINE.test(line))) {
|
||||||
|
result.push(...paragraph.map((line) => line.replace(/^\s+/, '')));
|
||||||
|
} else {
|
||||||
|
result.push(paragraph.map((line) => line.trim()).join(' '));
|
||||||
|
}
|
||||||
|
|
||||||
|
paragraph = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const line of lines) {
|
||||||
|
if (fence.update(line)) {
|
||||||
|
flushParagraph();
|
||||||
|
result.push(line);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isBlank(line)) {
|
||||||
|
flushParagraph();
|
||||||
|
result.push(line);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
paragraph.push(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
flushParagraph();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function collapseBlankLines(lines: string[]): string[] {
|
||||||
|
return lines.filter((line, index) => !(isBlank(line) && index > 0 && isBlank(lines[index - 1])));
|
||||||
|
}
|
||||||
|
|
||||||
|
function trimBlankLines(lines: string[]): string[] {
|
||||||
|
let start = 0;
|
||||||
|
let end = lines.length;
|
||||||
|
|
||||||
|
while (start < end && isBlank(lines[start])) {
|
||||||
|
start++;
|
||||||
|
}
|
||||||
|
while (end > start && isBlank(lines[end - 1])) {
|
||||||
|
end--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lines.slice(start, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
function canJoin(line: string, nextLine: string): boolean {
|
||||||
|
return (
|
||||||
|
!isBlank(line) &&
|
||||||
|
!isBlank(nextLine) &&
|
||||||
|
!SENTENCE_END.test(line.replace(/\s+$/, '')) &&
|
||||||
|
!UNWRAP_STOP_START.test(nextLine) &&
|
||||||
|
!FENCE_LINE.test(nextLine)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tracks whether a line sits inside a fenced code block.
|
||||||
|
// `update` returns true when the line is a fence line or lies inside a fence.
|
||||||
|
function createFenceTracker() {
|
||||||
|
let openMarker: string | undefined;
|
||||||
|
|
||||||
|
return {
|
||||||
|
update(line: string): boolean {
|
||||||
|
const marker = FENCE_LINE.exec(line)?.[1];
|
||||||
|
|
||||||
|
if (openMarker === undefined) {
|
||||||
|
if (marker) {
|
||||||
|
openMarker = marker;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (marker && marker[0] === openMarker[0] && marker.length >= openMarker.length) {
|
||||||
|
openMarker = undefined;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function countLines(text: string): number {
|
||||||
|
return text === '' ? 0 : text.split(/\r\n|\r|\n/).length;
|
||||||
|
}
|
||||||
|
|
||||||
|
function commonPrefix(a: string, b: string): string {
|
||||||
|
let length = 0;
|
||||||
|
while (length < a.length && length < b.length && a[length] === b[length]) {
|
||||||
|
length++;
|
||||||
|
}
|
||||||
|
return a.slice(0, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isBlank(line: string): boolean {
|
||||||
|
return line.trim() === '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function isWhitespace(char: string): boolean {
|
||||||
|
return /^\s$/.test(char);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isBulletChar(char: string): boolean {
|
||||||
|
return BULLET_CHARS.has(char);
|
||||||
|
}
|
||||||
|
|
||||||
|
// U+2500 to U+259F: box drawing and block elements. Arrows and geometric shapes are not frame characters.
|
||||||
|
function isFrameChar(char: string): boolean {
|
||||||
|
const codePoint = char.codePointAt(0) ?? 0;
|
||||||
|
return codePoint >= 0x2500 && codePoint <= 0x259f;
|
||||||
|
}
|
||||||
@@ -0,0 +1,334 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
const { t } = useI18n();
|
||||||
|
|
||||||
|
import { cleanText, computeStats } from './whitespace-cleaner.service';
|
||||||
|
import { OPTION_DEFINITIONS, getBrowserStorage, loadOptions, saveOptions } from './whitespace-cleaner.options';
|
||||||
|
import { SAMPLE_INPUT } from './whitespace-cleaner.sample';
|
||||||
|
import CInputText from '@/ui/c-input-text/c-input-text.vue';
|
||||||
|
|
||||||
|
type CopyState = 'idle' | 'copied' | 'failed';
|
||||||
|
|
||||||
|
const COPIED_DURATION_MS = 1500;
|
||||||
|
const INPUT_DEBOUNCE_MS = 100;
|
||||||
|
|
||||||
|
const storage = getBrowserStorage();
|
||||||
|
const options = ref(loadOptions(storage));
|
||||||
|
watch(options, (value) => saveOptions(storage, value), { deep: true });
|
||||||
|
|
||||||
|
const input = ref('');
|
||||||
|
// Debouncing keeps the cleaner and the output re-render out of the keystroke path for large pastes.
|
||||||
|
const debouncedInput = refDebounced(input, INPUT_DEBOUNCE_MS);
|
||||||
|
const output = computed(() => cleanText(debouncedInput.value, options.value));
|
||||||
|
const stats = computed(() => computeStats(debouncedInput.value, output.value));
|
||||||
|
|
||||||
|
const inputBadge = computed(() =>
|
||||||
|
debouncedInput.value === ''
|
||||||
|
? 'input'
|
||||||
|
: t('tools.whitespace-cleaner.texts.stats-value-inputlines-lines-stats-value-inputchars-chars', [
|
||||||
|
stats.value.inputLines,
|
||||||
|
stats.value.inputChars,
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
const outputBadge = computed(() =>
|
||||||
|
output.value === ''
|
||||||
|
? 'output'
|
||||||
|
: t(
|
||||||
|
'tools.whitespace-cleaner.texts.stats-value-outputlines-lines-stats-value-outputchars-chars-stats-value-savedpercent',
|
||||||
|
[stats.value.outputLines, stats.value.outputChars, stats.value.savedPercent],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
const outputField = ref<InstanceType<typeof CInputText>>();
|
||||||
|
const copyState = ref<CopyState>('idle');
|
||||||
|
const announcement = ref('');
|
||||||
|
|
||||||
|
const { start: startCopiedTimer, stop: stopCopiedTimer } = useTimeoutFn(
|
||||||
|
() => {
|
||||||
|
copyState.value = 'idle';
|
||||||
|
},
|
||||||
|
COPIED_DURATION_MS,
|
||||||
|
{ immediate: false },
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(output, () => {
|
||||||
|
stopCopiedTimer();
|
||||||
|
copyState.value = 'idle';
|
||||||
|
});
|
||||||
|
|
||||||
|
const copyLabel = computed(
|
||||||
|
() =>
|
||||||
|
({
|
||||||
|
idle: t('tools.token-generator.button.copy'),
|
||||||
|
copied: t('tools.whitespace-cleaner.texts.copied'),
|
||||||
|
failed: t('tools.whitespace-cleaner.texts.copy-failed'),
|
||||||
|
})[copyState.value],
|
||||||
|
);
|
||||||
|
|
||||||
|
function loadSample() {
|
||||||
|
input.value = SAMPLE_INPUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearInput() {
|
||||||
|
input.value = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleOption(key: keyof typeof options.value) {
|
||||||
|
options.value[key] = !options.value[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
async function announce(message: string) {
|
||||||
|
// Clearing first makes screen readers announce a repeated message again.
|
||||||
|
announcement.value = '';
|
||||||
|
await nextTick();
|
||||||
|
announcement.value = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Firefox scrolls a textarea to the end of a selection set by script, so selecting all would jump to the bottom.
|
||||||
|
// The scroll position is restored right away and again on the next frame, in case the browser scrolls later.
|
||||||
|
function changeSelectionKeepingScroll(textarea: HTMLTextAreaElement, changeSelection: () => void) {
|
||||||
|
const { scrollTop, scrollLeft } = textarea;
|
||||||
|
const restoreScroll = () => {
|
||||||
|
textarea.scrollTop = scrollTop;
|
||||||
|
textarea.scrollLeft = scrollLeft;
|
||||||
|
};
|
||||||
|
|
||||||
|
changeSelection();
|
||||||
|
restoreScroll();
|
||||||
|
requestAnimationFrame(restoreScroll);
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectAllKeepingScroll(textarea: HTMLTextAreaElement) {
|
||||||
|
changeSelectionKeepingScroll(textarea, () => textarea.select());
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectOutput() {
|
||||||
|
const textarea = outputField.value?.textareaRef;
|
||||||
|
if (textarea) {
|
||||||
|
textarea.focus();
|
||||||
|
selectAllKeepingScroll(textarea);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function copyOutput() {
|
||||||
|
if (output.value === '') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
stopCopiedTimer();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!navigator.clipboard?.writeText) {
|
||||||
|
throw new Error(t('tools.whitespace-cleaner.texts.the-clipboard-api-is-unavailable'));
|
||||||
|
}
|
||||||
|
|
||||||
|
await navigator.clipboard.writeText(output.value);
|
||||||
|
copyState.value = 'copied';
|
||||||
|
startCopiedTimer();
|
||||||
|
announce(t('tools.whitespace-cleaner.texts.copied-to-the-clipboard'));
|
||||||
|
} catch {
|
||||||
|
copyState.value = 'failed';
|
||||||
|
selectOutput();
|
||||||
|
announce(t('tools.whitespace-cleaner.texts.copy-failed-the-output-is-selected-press-ctrl-c-to-copy-it'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// A mouse press focuses the output before a drag starts. Selecting all on that focus would replace the drag selection,
|
||||||
|
// so a mouse focus is left to `selectAllOnClick`.
|
||||||
|
let isMouseFocus = false;
|
||||||
|
|
||||||
|
// A mouse press inside an existing selection starts a text drag instead of a new selection.
|
||||||
|
// Collapsing the selection first lets the user drag-select part of the output, and lets a plain click select all.
|
||||||
|
function prepareMouseSelection(event: MouseEvent) {
|
||||||
|
isMouseFocus = true;
|
||||||
|
|
||||||
|
const target = event.target;
|
||||||
|
if (
|
||||||
|
event.button !== 0 ||
|
||||||
|
event.shiftKey ||
|
||||||
|
!(target instanceof HTMLTextAreaElement) ||
|
||||||
|
target.selectionStart === target.selectionEnd
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
changeSelectionKeepingScroll(target, () => target.setSelectionRange(target.selectionStart, target.selectionStart));
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectAllOnFocus(event: FocusEvent) {
|
||||||
|
const focusedByMouse = isMouseFocus;
|
||||||
|
isMouseFocus = false;
|
||||||
|
|
||||||
|
if (!focusedByMouse && event.target instanceof HTMLTextAreaElement) {
|
||||||
|
selectAllKeepingScroll(event.target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectAllOnClick(event: MouseEvent) {
|
||||||
|
isMouseFocus = false;
|
||||||
|
const target = event.target;
|
||||||
|
if (target instanceof HTMLTextAreaElement && target.selectionStart === target.selectionEnd) {
|
||||||
|
selectAllKeepingScroll(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="whitespace-cleaner">
|
||||||
|
<div class="panes">
|
||||||
|
<section class="pane" aria-labelledby="whitespace-cleaner-input-label">
|
||||||
|
<div class="pane-header">
|
||||||
|
<div class="pane-title">
|
||||||
|
<label id="whitespace-cleaner-input-label" for="whitespace-cleaner-input" font-bold>{{
|
||||||
|
t('tools.whitespace-cleaner.texts.paste')
|
||||||
|
}}</label>
|
||||||
|
<n-tag size="small" round :bordered="false" data-test-id="input-badge">
|
||||||
|
{{ inputBadge }}
|
||||||
|
</n-tag>
|
||||||
|
</div>
|
||||||
|
<div class="pane-actions">
|
||||||
|
<c-button size="small" data-test-id="sample" @click="loadSample">
|
||||||
|
{{ t('tools.whitespace-cleaner.texts.sample') }}
|
||||||
|
</c-button>
|
||||||
|
<c-button
|
||||||
|
size="small"
|
||||||
|
:disabled="input === ''"
|
||||||
|
:aria-disabled="input === ''"
|
||||||
|
data-test-id="clear"
|
||||||
|
@click="clearInput"
|
||||||
|
>
|
||||||
|
{{ t('tools.multi-link-downloader.texts.tag-clear') }}
|
||||||
|
</c-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<CInputText
|
||||||
|
id="whitespace-cleaner-input"
|
||||||
|
v-model:value="input"
|
||||||
|
raw-text
|
||||||
|
multiline
|
||||||
|
monospace
|
||||||
|
rows="16"
|
||||||
|
:placeholder="t('tools.whitespace-cleaner.texts.paste-fragmented-claude-code-output-here')"
|
||||||
|
test-id="input"
|
||||||
|
/>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="pane" aria-labelledby="whitespace-cleaner-output-label">
|
||||||
|
<div class="pane-header">
|
||||||
|
<div class="pane-title">
|
||||||
|
<label id="whitespace-cleaner-output-label" for="whitespace-cleaner-output" font-bold>{{
|
||||||
|
t('tools.zalgo.texts.tag-clean')
|
||||||
|
}}</label>
|
||||||
|
<n-tag size="small" round :bordered="false" data-test-id="output-badge">
|
||||||
|
{{ outputBadge }}
|
||||||
|
</n-tag>
|
||||||
|
</div>
|
||||||
|
<div class="pane-actions">
|
||||||
|
<c-button
|
||||||
|
size="small"
|
||||||
|
:type="copyState === 'failed' ? 'error' : 'primary'"
|
||||||
|
:disabled="output === ''"
|
||||||
|
:aria-disabled="output === ''"
|
||||||
|
data-test-id="copy"
|
||||||
|
@click="copyOutput"
|
||||||
|
>
|
||||||
|
{{ copyLabel }}
|
||||||
|
</c-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<CInputText
|
||||||
|
id="whitespace-cleaner-output"
|
||||||
|
ref="outputField"
|
||||||
|
:value="output"
|
||||||
|
multiline
|
||||||
|
monospace
|
||||||
|
raw-text
|
||||||
|
readonly
|
||||||
|
rows="16"
|
||||||
|
:placeholder="t('tools.whitespace-cleaner.texts.your-cleaned-output-will-appear-here')"
|
||||||
|
test-id="output"
|
||||||
|
@mousedown="prepareMouseSelection"
|
||||||
|
@focusin="selectAllOnFocus"
|
||||||
|
@click="selectAllOnClick"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div v-if="output !== ''" class="output-hint" data-test-id="output-hint">
|
||||||
|
{{ t('tools.whitespace-cleaner.texts.ctrl-a-ctrl-c') }}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="chips" role="group" :aria-label="t('tools.whitespace-cleaner.texts.cleaning-options')">
|
||||||
|
<c-tooltip v-for="{ key, label, hint } in OPTION_DEFINITIONS" :key="key" :tooltip="hint">
|
||||||
|
<c-button
|
||||||
|
size="small"
|
||||||
|
round
|
||||||
|
:type="options[key] ? 'primary' : 'default'"
|
||||||
|
:aria-pressed="options[key]"
|
||||||
|
:data-test-id="`option-${key}`"
|
||||||
|
@click="toggleOption(key)"
|
||||||
|
>
|
||||||
|
<icon-mdi-check v-if="options[key]" mr-1 aria-hidden="true" />
|
||||||
|
{{ label }}
|
||||||
|
</c-button>
|
||||||
|
</c-tooltip>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="sr-only" role="status" aria-live="polite" data-test-id="copy-status">
|
||||||
|
{{ announcement }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
.whitespace-cleaner {
|
||||||
|
flex: 1 1 100% !important;
|
||||||
|
max-width: 1216px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panes {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1fr);
|
||||||
|
gap: 16px;
|
||||||
|
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.pane {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pane-header {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 8px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pane-title,
|
||||||
|
.pane-actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.output-hint {
|
||||||
|
margin-top: 4px;
|
||||||
|
font-size: 12px;
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chips {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in new issue
Block a user