Skip to content

fix: fix list with tabs#3891

Merged
UziTech merged 3 commits intomarkedjs:masterfrom
UziTech:list-tabs
Feb 11, 2026
Merged

fix: fix list with tabs#3891
UziTech merged 3 commits intomarkedjs:masterfrom
UziTech:list-tabs

Conversation

@UziTech
Copy link
Member

@UziTech UziTech commented Feb 9, 2026

Marked version: 17.0.1

Description

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 Feb 9, 2026

@UziTech is attempting to deploy a commit to the MarkedJS Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Feb 9, 2026

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

Project Deployment Actions Updated (UTC)
marked-website Ready Ready Preview, Comment Feb 9, 2026 6:21am

Request Review

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @UziTech, 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 an issue where markdown lists containing tab characters were not being processed correctly. By implementing a new expandTabs utility and integrating it into the tokenizer's list parsing logic, the change ensures that tabs are consistently expanded to spaces, leading to more accurate and predictable rendering of list structures. This enhancement improves the robustness of the markdown parser, particularly for content that uses tabs for indentation within lists.

Highlights

  • Improved Tab Handling in Lists: Introduced a dedicated expandTabs helper function to correctly convert tab characters within list items into spaces, ensuring consistent rendering.
  • Refactored List Tokenization Logic: The _Tokenizer class now utilizes the new expandTabs function, replacing a less robust regex-based tab replacement mechanism for list item lines.
  • Updated List Parsing Rules: Modified the regular expressions for list detection in src/rules.ts to explicitly account for tabs (\t) as valid separators after list markers, enhancing compatibility with various markdown styles.
  • Expanded Test Coverage: Added comprehensive test cases in test/specs/new/list_item_tabs.md and test/specs/new/list_item_tabs.html to validate the correct parsing and rendering of lists with different combinations of tabs and spaces.
Changelog
  • src/Tokenizer.ts
    • Imported the new expandTabs helper function.
    • Replaced the inline replace call for tab handling in list item lines with a call to expandTabs.
    • Updated the indent calculation to use the expanded line.
  • src/helpers.ts
    • Added a new expandTabs function that takes a string and an optional indent and converts tab characters to spaces, aligning them to 4-column tab stops.
  • src/rules.ts
    • Removed the listReplaceTabs regular expression, as its functionality is now handled by expandTabs.
    • Modified the list regular expressions within paragraph, gfmTable, and blockGfm to include [ \t] (space or tab) after the list marker, allowing for more flexible list parsing.
  • test/specs/new/list_item_tabs.html
    • Updated the expected HTML output to include various list examples demonstrating correct tab expansion.
  • test/specs/new/list_item_tabs.md
    • Added new markdown test cases featuring different combinations of spaces and tabs after list markers and within list item content.
Activity
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 👍 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

  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.

Copy link
Contributor

@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 correctly fixes an issue with tab handling in lists. It introduces a new expandTabs helper function to properly expand tabs to spaces based on standard 4-column tab stops, which aligns with the GFM specification. This function is now used in the tokenizer for list item processing. Additionally, the regex rules for paragraph interruption have been updated to correctly identify list items that use tabs as separators. The changes are accompanied by a comprehensive set of new tests that cover various scenarios with spaces and tabs in lists. The implementation appears solid and correct.

@UziTech UziTech merged commit 9fc4f8e into markedjs:master Feb 11, 2026
8 checks passed
github-actions bot pushed a commit that referenced this pull request Feb 11, 2026
## [17.0.2](v17.0.1...v17.0.2) (2026-02-11)

### Bug Fixes

* fix blockquote after list ([#3888](#3888)) ([2a475a1](2a475a1))
* fix empty list item ([#3890](#3890)) ([3fc6a44](3fc6a44))
* fix list item wrong indent ([#3889](#3889)) ([e031175](e031175))
* fix list with tabs ([#3891](#3891)) ([9fc4f8e](9fc4f8e))
* fix strikethrough flanking rules ([#3882](#3882)) ([1a5b124](1a5b124))
@UziTech UziTech deleted the list-tabs branch March 6, 2026 23:00
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.

Marked treats tabs and spaces differently in lists

2 participants