diff --git a/locales/en.yml b/locales/en.yml index a50c011b..17ea9246 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -53,7 +53,8 @@ about: favorites-imported-successfully: Favorites imported successfully! error-importing-favorites-e: 'Error importing favorites: {0}' 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 is a free and open-source collection of handy online tools for developers & people working in IT. @@ -120,7 +121,8 @@ home: themeDark: Dark page: 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 is a free and open-source collection of handy online tools for developers & people working in IT. @@ -1594,7 +1596,7 @@ tools: label-code-snippet-to-format: 'Code snippet to format:' placeholder-put-your-code-snippet-here: Put your code snippet here label-show-line-numbers: Show line numbers - tag-: ''', ''' + tag-: "', '" tag-copy-html-formatted: Copy HTML Formatted tag-copy-code-text: Copy Code Text tag-copy-html-word: Copy to HTML/Rich text in Word @@ -2275,9 +2277,9 @@ tools: label-advanded-json-mode: Advanded JSON Mode title-prompts: Prompts 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... - 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) placeholder-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})' token-secret: Token Secret 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 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 @@ -4174,7 +4176,8 @@ tools: 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-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 only copy cookies available to javascript (HTTP only and secure cookies will be omitted). @@ -4866,25 +4869,29 @@ tools: 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 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 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-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 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:  tag-https-www-tcpdump-org-manpages-tcpdump-1-html: https://www.tcpdump.org/manpages/tcpdump.1.html 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. Separate your entries with a comma, space, or semicolon. 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, 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 @@ -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-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). Each RAID 7 set can sustain three drive failures. 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-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). Each RAID 5 set can sustain a single drive failure. 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-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 is mirrored and striped together so that each drive in the set is fault tolerant within the group. 3-drive-failures: 3 drive failures 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 with a third parity block. This allows for a third disk failure at the cost of storage reduction equal to three drives. 2-drive-failures: 2 drive failures 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 allows for an additional disk failure at the cost of storage reduction equal to two drives. 1-drive-failure: 1 drive failure 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 tolerance with a storage reduction equal to one drive for the parity information. 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 more disks. The array will operate as long as at least one drive is operational. 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 fault tolerance creating one large storage space. categories: @@ -5396,14 +5411,16 @@ tools: text: source-wikipedia: 'Source: Wikipedia' 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 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). 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). 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 Francesco Cirillo in the 1980s. It uses a timer to break work into intervals, typically 25 minutes in length, separated by short breaks. @@ -5615,7 +5632,7 @@ tools: service: text: 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: title: Color converter 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... tag-duration-to-crack-this-password-with-brute-force: Duration to crack this password with brute force 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 password using a brute force approach, it does not take into account the possibility of a dictionary attack. @@ -5835,7 +5853,7 @@ tools: song-details: Song details twitter: 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. the-name-of-the-twitter-account-of-the-site-ex-ittoolsdottech: >- 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 ability to fulfill the request. 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 encountered and no more specific message is suitable. internal-server-error: Internal 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 resource or to a set of resources that includes the requested resource. 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 individual header field, or all the header fields collectively, are too large. @@ -6685,7 +6706,8 @@ tools: Indicates that the resource requested is no longer available and will not be available again. 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 in the request, such as an edit conflict. conflict: Conflict @@ -6693,7 +6715,8 @@ tools: request-timeout: Request Timeout the-client-must-first-authenticate-itself-with-the-proxy: The client must first authenticate itself with the proxy. 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 acceptable according to the Accept headers sent in the request. 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-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 might not have the necessary permissions for a resource. 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 might be used as part of some form of digital cash or micropayment scheme. 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 is required and has failed or has not yet been provided. unauthorized: Unauthorized @@ -6724,7 +6750,8 @@ tools: The request and all future requests should be repeated using another URI. 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; however, future requests should still use the original URI. temporary-redirect: Temporary Redirect @@ -7314,7 +7341,8 @@ tools: label-failure-probability: 'Failure Probability:' tag-key-terms-explained: ๐Ÿง  Key Terms Explained 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 multiple physical drives into one logical unit to improve performance, redundancy, or both. @@ -7344,34 +7372,41 @@ tools: Stripe of RAID 5 arrays. Combines performance of RAID 0 with redundancy of RAID 5. 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 failing. Higher MTBF means more reliable hardware. 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 failure. Longer rebuild times increase the risk of a second failure during recovery. 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 loss occurs. It considers drive failures, rebuild time, and RAID redundancy. Higher MTTDL means a safer system. 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 hardware limitations. Even tiny BERs (like 1 in a trillion) can cause issues during rebuilds, especially with large drives. 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 contributes to URE risk, which can compromise RAID recovery. 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 more susceptible to BER-related errors. 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 time period (e.g., 5 years). Calculated using MTTDL and exponential failure models. @@ -7729,7 +7764,8 @@ tools: tag-mirrors-stripes: Mirrors/Stripes tag-reset: Reset 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. Hovering over a table cell loads the relevant data into the Calculation 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 and check for audio clarity. 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: texts: title-input: Input diff --git a/src/tools/whitespace-cleaner/index.ts b/src/tools/whitespace-cleaner/index.ts new file mode 100644 index 00000000..f0309c54 --- /dev/null +++ b/src/tools/whitespace-cleaner/index.ts @@ -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', +}); diff --git a/src/tools/whitespace-cleaner/whitespace-cleaner.e2e.spec.ts b/src/tools/whitespace-cleaner/whitespace-cleaner.e2e.spec.ts new file mode 100644 index 00000000..c250df77 --- /dev/null +++ b/src/tools/whitespace-cleaner/whitespace-cleaner.e2e.spec.ts @@ -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(''); + }); +}); diff --git a/src/tools/whitespace-cleaner/whitespace-cleaner.options.test.ts b/src/tools/whitespace-cleaner/whitespace-cleaner.options.test.ts new file mode 100644 index 00000000..0ff60f94 --- /dev/null +++ b/src/tools/whitespace-cleaner/whitespace-cleaner.options.test.ts @@ -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 = {}) { + 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(); + }); +}); diff --git a/src/tools/whitespace-cleaner/whitespace-cleaner.options.ts b/src/tools/whitespace-cleaner/whitespace-cleaner.options.ts new file mode 100644 index 00000000..996ef39b --- /dev/null +++ b/src/tools/whitespace-cleaner/whitespace-cleaner.options.ts @@ -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 | 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)[key]; + if (typeof value === 'boolean') { + options[key] = value; + } + } + + return options; + } catch { + return getDefaultOptions(); + } +} + +export function saveOptions(storage: Pick | 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; + } +} diff --git a/src/tools/whitespace-cleaner/whitespace-cleaner.sample.ts b/src/tools/whitespace-cleaner/whitespace-cleaner.sample.ts new file mode 100644 index 00000000..56a96d52 --- /dev/null +++ b/src/tools/whitespace-cleaner/whitespace-cleaner.sample.ts @@ -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'); diff --git a/src/tools/whitespace-cleaner/whitespace-cleaner.service.test.ts b/src/tools/whitespace-cleaner/whitespace-cleaner.service.test.ts new file mode 100644 index 00000000..4d1f1980 --- /dev/null +++ b/src/tools/whitespace-cleaner/whitespace-cleaner.service.test.ts @@ -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); + }); + }); +}); diff --git a/src/tools/whitespace-cleaner/whitespace-cleaner.service.ts b/src/tools/whitespace-cleaner/whitespace-cleaner.service.ts new file mode 100644 index 00000000..96ac0000 --- /dev/null +++ b/src/tools/whitespace-cleaner/whitespace-cleaner.service.ts @@ -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; +} diff --git a/src/tools/whitespace-cleaner/whitespace-cleaner.vue b/src/tools/whitespace-cleaner/whitespace-cleaner.vue new file mode 100644 index 00000000..4ddb0349 --- /dev/null +++ b/src/tools/whitespace-cleaner/whitespace-cleaner.vue @@ -0,0 +1,334 @@ + + + + +