-
Notifications
You must be signed in to change notification settings - Fork 3.5k
bug: Marked treats tabs and spaces differently in lists #3784
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
base: master
Are you sure you want to change the base?
Conversation
|
@akilesh1706 is attempting to deploy a commit to the MarkedJS Team on Vercel. A member of the Team first needs to authorize it. |
Summary of ChangesHello @akilesh1706, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a parsing inconsistency in the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this 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 correctly addresses an inconsistency in how tabs are handled within lists, and the new tests provide good coverage for the fix. However, I've identified a critical indentation error that appears to be accidental and would break list parsing. Additionally, I've provided a couple of suggestions to improve the clarity and efficiency of the updated tokenizer logic.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
test/unit/marked.test.js
Outdated
| const __filename = fileURLToPath(import.meta.url); | ||
| const __dirname = path.dirname(__filename); | ||
|
|
||
| const mdPath = path.join(__dirname, '../specs/new/list_with_tabs.md'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not needed. the files in the new folder are already ran in other tests
|
Necessary changes done, requesting for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests don't pass
|
@akilesh1706 are you planning on continuing to work on this? |
Yes, I'm resolving the CI test passes. |
Marked version: 11.0.0 (bug reported against 11.0.0). Fix implemented on master.
Markdown flavor: CommonMark / GitHub Flavored Markdown (GFM)
Description
When a list item used a tab after the list marker (e.g. 1.\tText or -\tText), and there was preceding text (a paragraph) before the list, the tokenizer sometimes treated the item content as an indented code block (leading four spaces) instead of normal list content. This produced
This PR fixes that inconsistency so tabs after the marker are interpreted the same as spaces regardless of text preceding the list.
Fixes the inconsistent tab handling in list items that could make tabbed list items render as indented code blocks.
Files changed (key):
Expectation
Given input (tabs or spaces after marker):
I am using spaces after the number:
Some Text
Some Text
Some Text
I am using tabs after the number: 1. Some Text 2. Some Text 3. Some Text
Expected HTML (both cases):
(And similar for unordered lists)
Result (before this PR)
Lists that used tabs after the marker were sometimes parsed as indented code blocks and rendered as:
while the same lists using spaces were parsed/rendered correctly as simple
What was attempted / what this PR does
Normalizes the first line of a list item by replacing tabs with the same tab normalization used elsewhere in the codebase (tabs -> 4 spaces), then computes indent and slices content from the normalized string so the slice length is correct when tabs are used.
Ensures indent detection replaces tabs with spaces consistently when finding the first non-space character.
Adds tests to cover:
ordered lists using spaces vs tabs,
ordered lists that follow a paragraph (the reported scenario),
unordered lists using spaces vs tabs.