Skip to content

Conversation

@UziTech
Copy link
Member

@UziTech UziTech commented Sep 7, 2025

Marked version: 16.2.1

Description

Allow provideParser and provideLexer to be async functions.

Contributor

  • Test(s) exist to ensure functionality and minimize regression (if no tests added, list tests covering this PR); or,
  • no tests required for this PR.
  • If submitting new feature, it has been documented in the appropriate places.

Committer

In most cases, this should be a different person than the contributor.

@vercel
Copy link

vercel bot commented Sep 7, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
marked-website Ready Ready Preview Comment Sep 16, 2025 3:54am

@UziTech UziTech force-pushed the async-provide-parser-lexer branch from 6e1c3f9 to 8f78206 Compare September 16, 2025 02:57
@UziTech UziTech marked this pull request as ready for review September 16, 2025 03:01
@UziTech
Copy link
Member Author

UziTech commented Sep 16, 2025

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully adds support for asynchronous provideParser and provideLexer hooks, which is a great enhancement. The implementation is correct and includes appropriate tests. My review includes a couple of suggestions to refactor parts of the asynchronous logic to use async/await. This will improve code readability and maintainability, making the code easier to understand and work with in the future.

@UziTech UziTech changed the title Async-provide-parser-lexer feat: Add async provideParser provideLexer Sep 16, 2025
@UziTech
Copy link
Member Author

UziTech commented Sep 16, 2025

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces asynchronous functionality for provideParser and provideLexer hooks, which is a great enhancement. The implementation correctly uses async/await to handle the new asynchronous nature of these hooks. I've made a few suggestions to improve code consistency within the new async processing block and to expand test coverage to ensure all new asynchronous paths are validated.

@UziTech
Copy link
Member Author

UziTech commented Sep 16, 2025

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for asynchronous provideParser and provideLexer hooks. The changes correctly refactor the parsing pipeline to use async/await when async mode is enabled, allowing these hooks to return promises. The implementation is sound, and new tests have been added to cover the new asynchronous functionality. I have one suggestion to improve code consistency and maintainability.

@UziTech
Copy link
Member Author

UziTech commented Sep 17, 2025

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully adds asynchronous capabilities to provideParser and provideLexer hooks, including comprehensive tests for the new functionality. The conversion of promise chains to async/await syntax improves code readability. However, the implementation introduces significant code duplication in src/Instance.ts to handle both synchronous and asynchronous execution paths. I've left two comments highlighting these areas, with severities of 'medium' and 'high', as they impact maintainability. Addressing this duplication would greatly improve the quality of the changes.

@UziTech
Copy link
Member Author

UziTech commented Oct 4, 2025

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds the ability for provideParser and provideLexer hooks to be asynchronous, which is a great feature enhancement. The implementation correctly refactors the asynchronous parsing path to use async/await and handles the new async hooks.

However, I've found a critical issue in the synchronous parsing path. If a user provides an async hook for provideLexer or provideParser but does not enable the async: true option, the application will hit a runtime error because it will try to execute a Promise as a function. I've left a specific comment with more details on how to address this to make the API safer and more robust for developers.

The added tests cover the new functionality well for the asynchronous cases.

@UziTech UziTech merged commit 09577e5 into markedjs:master Oct 7, 2025
8 checks passed
@UziTech UziTech deleted the async-provide-parser-lexer branch October 7, 2025 03:22
github-actions bot pushed a commit that referenced this pull request Oct 7, 2025
# [16.4.0](v16.3.0...v16.4.0) (2025-10-07)

### Bug Fixes

* Fix backtick and code rendering in links ([#3783](#3783)) ([302ee59](302ee59))
* fix links with square brackets in inline code break wrapping italics ([#3785](#3785)) ([e3c0d3e](e3c0d3e))
* Make `www` case-sensitive when detecting link starts ([#3770](#3770)) ([626d961](626d961))

### Features

* Add async provideParser provideLexer ([#3756](#3756)) ([09577e5](09577e5))
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