bug: Marked treats tabs and spaces differently in lists
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
... inside 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:
Some Text ...
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.
@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 Changes
Hello @akilesh1706, I'm Gemini Code Assist[^1]! 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 Marked library where list items using tabs after their markers were sometimes misinterpreted as indented code blocks, particularly when following a paragraph. The changes normalize tab characters to spaces during the initial processing of list item lines and refine indent calculation, ensuring that Marked consistently renders list items whether tabs or spaces are used after the marker. This improves the robustness and predictability of markdown rendering.
Highlights
- Inconsistent List Parsing: Fixed a bug where
Markedinconsistently parsed list items, treating content after a tab-separated marker as an indented code block instead of normal list content, especially when preceded by a paragraph. - Tab Normalization: Implemented consistent normalization of tabs to 4 spaces within list item parsing logic, ensuring uniform handling of tabs and spaces after list markers.
- Improved Indent Calculation: Enhanced the indent calculation for list items to correctly account for tabs by treating them as 4 spaces when determining the first non-space character.
- Comprehensive Testing: Added new unit tests covering ordered and unordered lists with both tabs and spaces after markers, including the specific scenario of lists following a paragraph, to validate the fix.
Using Gemini Code Assist
The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.
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 :thumbsup: and :thumbsdown: 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.
[^1]: Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.
The latest updates on your projects. Learn more about Vercel for GitHub.
| Project | Deployment | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| marked-website | Preview | Comment | Oct 4, 2025 4:52am |
Necessary changes done, requesting for review.
@akilesh1706 are you planning on continuing to work on this?
@akilesh1706 are you planning on continuing to work on this?
Yes, I'm resolving the CI test passes.