marked icon indicating copy to clipboard operation
marked copied to clipboard

Add Support for Customizable Tab Handling in Markdown Code Blocks

Open ArfaNada opened this issue 11 months ago • 2 comments

Description

Marked.js currently lacks support for customizable tab handling within Markdown code blocks. This feature would allow users to specify tab width and customize tab behavior within code blocks, enhancing the flexibility and usability of Marked.js for Markdown parsing.

Why is this feature necessary? The ability to customize tab handling is essential for users who work with Markdown documents containing code blocks. Different projects and coding styles may require varying tab widths and behaviors, and providing this customization option would improve the overall experience of using Marked.js for Markdown rendering. @daniel-santos @timabbott @zulip (https://github.com/zulip/zulip/issues/29044)

Proposal I propose extending Marked.js to support the parsing of Markdown code blocks with customizable tab handling. This enhancement would involve adding functionality to interpret additional parameters within code blocks, such as specifying the tab width using a syntax like ts=. Implementation Details To implement this feature, the following steps could be taken:

  1. Extend the parser to recognize and interpret the ts= syntax within fenced code blocks.
  2. Implement logic to adjust the tab width based on the specified parameter .
  3. Ensure that the parsing of code blocks remains efficient and compatible with existing Markdown syntax.

Benefits • Provides users with greater control over tab handling within code blocks, accommodating projects that still use tabs for indentation. • Enhances the versatility and usability of Marked.js for a wider range of Markdown formatting requirements.

Alternatives Considered Alternative solutions might include using external Markdown rendering libraries or manually processing Markdown documents to customize tab behavior. However, these approaches are less efficient and would require additional effort from users.

By adding support for customizable tab handling in Markdown code blocks, Marked.js can better align with established Markdown specifications and meet the diverse needs of its user base.

ArfaNada avatar Mar 11 '24 16:03 ArfaNada

Marked.js can better align with established Markdown specifications and meet the diverse needs of its user base.

I'm curious which markdown specifications include this?

UziTech avatar Mar 11 '24 22:03 UziTech

I'm not aware of any; as I noted in https://github.com/zulip/zulip/issues/29044 which seems to have inspired @ArfaNada to open this issue, my question there was whether there is any prior art for the original reporter's problem statement. So I think @ArfaNada might have been confused.

timabbott avatar Apr 01 '24 18:04 timabbott