Skip to content

[TEST ONLY - DO NOT MERGE] feat(replace-quotes.js): updating the script #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

mariana-caetano
Copy link

@mariana-caetano mariana-caetano commented Apr 2, 2025

[This pull request is for testing purposes only and should not be merged]

This pull request updates the replace-quotes.js script to handle additional edge cases related to title fields in Markdown files. It also includes a list of test .md files in the docs/pt/announcements directory to validate the script's functionality.


Changes Made

1. Enhancements to replace-quotes.js

Improve the script to handle additional edge cases for title fields in Markdown files.

  • Filepath: help-center-content\docs-utils\replace-quotes.js
  • Changes (Lines 12 to 68):
    • Handle empty or whitespace-only titles:

      • Detects title: empty fields or containing only spaces.
      • Logs a warning and skips processing.
      • Example:
        title:
    • Fix unquoted titles:

      • Adds double quotes around unquoted title fields.
      • Replaces internal double quotes with single quotes.
      • Example: from title: Hello world to title: "Hello world"
    • Fix double-quoted titles:

      • Converts outer double quotes to single quotes.
      • Example: from title: "Hello "world"" to title: 'Hello "world"'
    • Fix single-quoted titles with nested single quotes:

      • Converts outer single quotes to double quotes.
      • Example: from title: 'Hello 'world'' to title: "Hello 'world'"
    • Handle mixed quotes:

      • Keeps outer double quotes and leaves inner single quotes unchanged.
      • Example: from title: "Hello 'world'" remains title: "Hello 'world'"
    • Handle escaped quotes:

      • Detects escaped quotes (e.g., \") and logs them without modifying them.
      • Example: from title: "Hello \"world\"" remains title: "Hello \"world\""
    • Handle multiline titles:

      • Detects multiline title fields and logs a warning.
      • Example:
        title: "Hello
        world"
        Logs a warning and skips processing.

2. Updated index.js

Retained the call to replaceQuotes while commenting out unrelated functions (fixCallouts and updateAllImages) during testing.

  • Filepath: help-center-content\index.js
  • Added logs to indicate the progress of title adjustments.

3. Deleted original files in the docs directory

  • Reason:
    • Have a control environment test with only a few files, ensuring that only the newly added test files are processed during script execution.
    • Avoid interference when testing the replace-quotes.js script.

4. List of test .md Files

  • Directory: help-center-content\docs\pt\announcements
  • Purpose: Validate the replace-quotes.js script against various edge cases.
  • Test files:
    1. 2025-04-02-announcement-test-apostrophe-one.md:
      • Tests handling of titles with apostrophes.
      • Example:
        title: "I can't access the Headless CMS"
    2. 2025-04-02-announcement-test-com-crase-e-aspas.md:
      • Tests handling of titles with backticks and single quotes.
      • Example:
        title: "A partir de `13/11 APIs VTEX` deixarão de 'suportar' autenticação por e-mail e senha"
    3. test-empty-title.md:
      • Tests handling of empty title fields.
      • Example:
        title:
    4. test-whitespace-title.md:
      • Tests handling of whitespace-only title fields.
      • Example:
        title:    
    5. test-unquoted-title.md:
      • Tests handling of unquoted title fields.
      • Example:
        title: Hello world
    6. test-double-quoted-title.md:
      • Tests handling of double-quoted title fields with nested quotes.
      • Example:
        title: "Hello "world""
    7. test-single-quoted-nested-title.md:
      • Tests handling of single-quoted title fields with nested single quotes.
      • Example:
        title: 'Hello 'world''
    8. test-mixed-quotes.md:
      • Tests handling of mixed quotes in title fields.
      • Example:
        title: "Hello 'world'"
    9. test-escaped-quotes.md:
      • Tests handling of escaped quotes in title fields.
      • Example:
        title: "Hello \"world\""
    10. test-special-characters.md:
      • Tests handling of special characters in title fields.
      • Example:
        title: "Hello @#$%^&*()"
    11. test-multiline-title.md:
      • Tests handling of multiline title fields.
      • Example:
        title: "Hello
        world"

How to test locally

1 Clone this repository
2. Checkout to the branch EDU-13262.
3. Open a terminal and make sure you are in the following directory: help-center-content/index.js
4. Run the following command:

node index.js
  1. Verify the logs to ensure all test files are processed correctly.
  2. Check the updated .md files in the docs/pt/announcements directory to confirm that the title fields are formatted as expected.

Next Steps

  • If the script works as expected, we should open a new pull request with only the updated replace-quotes.js file.
  • Ensure the docs directory remains unchanged in the new pull request.

@mariana-caetano mariana-caetano changed the title [EDU-13262] feat(replace-quotes.js): updating the script [TEST ONLY] feat(replace-quotes.js): updating the script Apr 10, 2025
@mariana-caetano mariana-caetano changed the title [TEST ONLY] feat(replace-quotes.js): updating the script [TEST ONLY - DO NOT MERGE] feat(replace-quotes.js): updating the script Apr 10, 2025
@mariana-caetano mariana-caetano marked this pull request as ready for review April 11, 2025 14:31
@mariana-caetano mariana-caetano self-assigned this Apr 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant