Skip to content
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

fix: allow multiple option for slugify #287

Merged
merged 6 commits into from
Jan 26, 2024
Merged

fix: allow multiple option for slugify #287

merged 6 commits into from
Jan 26, 2024

Conversation

Mara-Li
Copy link
Member

@Mara-Li Mara-Li commented Jan 26, 2024

Summary by CodeRabbit

  • Refactor
    • Improved readability and functionality of link conversion logic.
  • New Features
    • Introduced enhanced settings for link slugification, allowing for more customized anchor handling.
  • Documentation
    • Updated interface documentation to reflect changes in slugify settings options.

Copy link

coderabbitai bot commented Jan 26, 2024

Walkthrough

The recent update focuses on enhancing the slugification process for anchor links in Markdown files and refining the settings interface for GitHub publishing. It introduces a more versatile approach to slugify anchor links, accommodating different settings, and updates the settings UI to reflect these new options. This change aims to improve the readability and customization of Markdown link conversion and settings management.

Changes

File Path Summary
src/conversion/links.ts Updated import formatting, refactored createMarkdownLinks, added slugifyAnchor function, modified convertToInternalGithub for anchor slugification.
src/settings.ts, src/settings/interface.ts and src/settings/interface.ts Modified dropdown for slugify settings in GithubPublisherSettingsTab, updated GitHubPublisherSettings interface and DEFAULT_SETTINGS for new slugify options.

🐇✨
In a burrow, deep and wide,
Changes bloom like spring outside.
Links now flow with graceful tide,
Settings dance, in harmony they glide.
🌟🌿

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between a9c32e6 and d169b38.
Files ignored due to path filters (2)
  • src/i18n/locales/en.json is excluded by: !**/*.json
  • src/i18n/locales/fr.json is excluded by: !**/*.json
Files selected for processing (3)
  • src/conversion/links.ts (3 hunks)
  • src/settings.ts (1 hunks)
  • src/settings/interface.ts (2 hunks)
Additional comments: 5
src/settings/interface.ts (2)
  • 119-119: The slugify property type has been updated to a union type to support multiple slugification strategies. This change enhances flexibility but ensure that all parts of the codebase that interact with this property can handle the new types correctly.
  • 281-281: The default value for the slugify property in DEFAULT_SETTINGS has been correctly updated to "disable", aligning with the new union type. This change ensures that the default behavior is explicitly defined.
src/conversion/links.ts (2)
  • 208-208: The slugifyWithSettings function is used in createMarkdownLinks to handle anchor slugification. This integration ensures that anchors are processed according to user-configured settings, enhancing flexibility. However, verify that encodeURI is applied after slugification to ensure all characters in the resulting URL are correctly encoded.
  • 303-304: The use of slugifyWithSettings in convertToInternalGithub for anchor handling is consistent with the PR's objectives. Ensure that the slugification settings are correctly passed down to this function from the settings interface to maintain consistency across the application.
src/settings.ts (1)
  • 733-753: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-1183]

Ensure that all external calls to the Obsidian API and interactions with plugin settings are correctly handled with error checking and validation where applicable. This includes verifying the existence of settings before accessing them and handling potential API changes gracefully.

Consider adding checks for the existence of settings and validating API responses to prevent runtime errors. This is particularly important for plugin development in Obsidian, where API changes can occur.

src/settings.ts Outdated Show resolved Hide resolved
src/settings.ts Outdated Show resolved Hide resolved
src/conversion/links.ts Outdated Show resolved Hide resolved
@Mara-Li
Copy link
Member Author

Mara-Li commented Jan 26, 2024

@coderabbitai review

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between d169b38 and 5596eec.
Files selected for processing (2)
  • src/conversion/links.ts (3 hunks)
  • src/settings.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/settings.ts
Additional comments: 3
src/conversion/links.ts (3)
  • 7-13: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-10]

The import statements are reformatted for better readability, which is a positive change. However, ensure that all imported modules are used within the file to avoid unnecessary imports that could lead to increased bundle size and slower load times.

  • 205-208: The integration of slugifyAnchor in createMarkdownLinks for handling anchors is correctly implemented. However, ensure that the slugifyAnchor function's behavior aligns with all possible anchor scenarios, including those without special characters or spaces, to maintain consistent slugification across different settings.
  • 303-304: The use of slugifyAnchor within convertToInternalGithub for anchor handling is appropriate and aligns with the PR's objective to enhance slugification flexibility. However, verify that this change does not introduce any regressions in link conversion, especially for links without anchors or with complex anchor formats.

src/conversion/links.ts Outdated Show resolved Hide resolved
@Mara-Li
Copy link
Member Author

Mara-Li commented Jan 26, 2024

@coderabbitai review

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 5596eec and 624073f.
Files selected for processing (1)
  • src/conversion/links.ts (3 hunks)
Additional comments: 3
src/conversion/links.ts (3)
  • 7-13: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-10]

The reformatting of import statements improves readability and organization. Ensure that all used imports are necessary and that there are no unused imports left.

  • 205-208: The integration of slugifyAnchor within createMarkdownLinks for anchor handling is a good application of the new functionality. However, ensure that the slugifyAnchor function's return value is correctly handled in all cases, especially considering its default behavior for non-disabled settings.
  • 306-307: The use of slugifyAnchor in convertToInternalGithub for anchor slugification aligns with the objective of making slugification more configurable. This change ensures consistency in how anchors are handled across different parts of the code. Verify that all possible anchor formats are correctly handled by slugifyAnchor to avoid breaking changes.

Ensure that the slugifyAnchor function is tested with various anchor formats to confirm its robustness and compatibility with existing markdown links.

src/conversion/links.ts Show resolved Hide resolved
@Mara-Li Mara-Li merged commit fbcb02c into master Jan 26, 2024
@Mara-Li Mara-Li deleted the slug-options branch January 26, 2024 21:02
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