Skip to content

Conversation

@powerivq
Copy link
Collaborator

@powerivq powerivq commented Jun 7, 2025

This is to address an issue that the titles' anchors are not sanitized properly, leaving dots and parenthesises there. This is not consistent with how github renders its page. We hereby remove them the same way.

I elected to use a new function name, instead of rewriting the slug function, to ensure that we do not accidentally fallback to the system default function.

@powerivq powerivq force-pushed the slug-generator-new branch 4 times, most recently from 89b45ec to b1d8f6e Compare June 7, 2025 06:13
@powerivq powerivq force-pushed the slug-generator-new branch from b1d8f6e to 43338ea Compare June 7, 2025 17:54
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances slug generation by sanitizing dots and parentheses in title anchors, ensuring consistency with GitHub's rendering.

  • Updates the sanitization logic in generalReferenceLinker.js to remove dots and parentheses.
  • Adds a test case in CodeSection.test.js for verifying the new heading escaping behavior.
  • Modifies CodeSection.js to apply consistent slug sanitization.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
platform/lib/tools/generalReferenceLinker.js Updated slug sanitization to remove dots and parentheses
platform/lib/samples/CodeSection.test.js Added test to verify heading sanitation
platform/lib/samples/CodeSection.js Updated heading id generation with enhanced sanitization logic
Comments suppressed due to low confidence (1)

platform/lib/tools/generalReferenceLinker.js:247

  • The slug sanitization logic here is similar to what is used elsewhere in the project. Consider extracting this logic into a shared utility function to promote consistency and reduce duplication.
const sectionId = section !== null ? section[0].replace(/\s/g, '').replace(/\./g, '-').replace(/[\(\)]/g, '') : '';

Comment on lines 274 to 277
let id = name.toLowerCase();
id = id.replace(/\s+/g, '-');
id = id.replace(/\./g, '-');
id = id.replace(/[\(\)]/g, '');
Copy link

Copilot AI Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar slug transformation logic is implemented here. Consider refactoring to use a common helper function for slug generation to ensure consistency across the codebase.

Suggested change
let id = name.toLowerCase();
id = id.replace(/\s+/g, '-');
id = id.replace(/\./g, '-');
id = id.replace(/[\(\)]/g, '');
const id = generateSlug(name);

Copilot uses AI. Check for mistakes.
@powerivq powerivq force-pushed the slug-generator-new branch from ce3fdfc to 7a4aeb9 Compare June 12, 2025 05:00
@powerivq powerivq merged commit ad54418 into main Jun 13, 2025
23 checks passed
@powerivq powerivq deleted the slug-generator-new branch June 13, 2025 17:22
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.

3 participants