BREAKING CHANGE: trim blank lines from block tokens#3939
BREAKING CHANGE: trim blank lines from block tokens#3939UziTech merged 8 commits intomarkedjs:masterfrom
Conversation
|
@UziTech is attempting to deploy a commit to the MarkedJS Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Code Review
This pull request modifies the Tokenizer to consistently trim trailing newlines and blank lines from various block tokens, including headings, code blocks, and HTML, to improve output consistency. It also extends the rtrim utility to support RegExp by reversing the input string. Review feedback highlights a typo in the reverseBlankLines regular expression and recommends optimizing the rtrim implementation for better performance and Unicode safety when reversing strings.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the rtrim helper function to support regular expressions and introduces a reverseBlankLines rule to better handle trailing blank lines in token parsing. I have reviewed the changes and suggest updating the reverseBlankLines regular expression to explicitly match only spaces and tabs, as per the CommonMark specification, to improve clarity and consistency.
# [18.0.0](v17.0.6...v18.0.0) (2026-04-07) ### Bug Fixes * Bump typescript from 5.9.3 to 6.0.2 ([#3934](#3934)) ([e8efc51](e8efc51)) * prevent GFM table tokens from greedily capturing trailing newlines ([#3926](#3926)) ([40f2665](40f2665)) * prevent heading and def tokens from greedily capturing multiple newlines ([#3925](#3925)) ([b379e3e](b379e3e)) * trim blank lines from block tokens ([#3939](#3939)) ([b70895f](b70895f)) ### BREAKING CHANGES * trim trailing blank lines from block tokens * update Typescript to v6
Marked version: 17.0.6
Description
Following #3925 and #3926
Remove trailing newlines from HTML block and remove blank lines from indented code blocks.
This makes all block tokens consistent in trimming newlines from raw and adding a space token for blank lines after block tokens.
This also fixes a bug where marked does not follow CommonMark. CommonMark trims trailing blank lines in an indented code block even if there are more than 4 spaces in the line. marked currently adds the blank lines to the code block if it has more than 4 spaces.
marked demo
CommonMark demo
Contributor
Committer
In most cases, this should be a different person than the contributor.