You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Python-Markdown currently lacks built-in support for tab customization in code blocks. This feature would allow users to specify the tab width within code blocks, enhancing flexibility and compatibility with various coding standards.
Why is this feature necessary
Different coding standards and preferences exist regarding tab width. By allowing users to customize tab width within code blocks, Python-Markdown can better accommodate these diverse requirements. This feature would improve the accuracy of code representation in Markdown documents, especially when copying code from IDEs or text editors.
Proposed Solution
Modify Parser: Extend the Markdown parser to recognize additional parameters in code block declarations, such as ts=, where denotes the desired tab width.
Implement Tab Handling: Introduce logic to handle tab width settings within code blocks according to the specified parameter.
Provide Default Behavior: Define a default tab width behavior to maintain backward compatibility while allowing users to override it as needed.
Alternative Solutions
Third-Party Extensions: Users can currently explore third-party extensions that might offer similar functionality. However, native support within Python-Markdown would streamline the process and ensure compatibility with future updates.
Manual Formatting: Users can manually adjust tab widths within code blocks, but this approach is cumbersome and prone to errors.
Considering Python-Markdown's focus on adhering to Markdown syntax rules, the proposed feature aligns with enhancing the flexibility and usability of the library without deviating from Markdown standards.
The text was updated successfully, but these errors were encountered:
If you'd like, you can use SuperFences to preserve tabs. This accounts for code blocks earlier, before Python Markdown normalizes tabs to spaces. Then you can style them however you want.
I'm not sure how we would accomplish this as the first thing the parser does is strip all tabs from a document and replace those tabs with spaces. This is done before any parsing happens so code blocks have not been identified yet and there would be no way to differentiate and avoid code blocks at that stage. While we could change/remove that behavior, it would require the entire parser to now account for tabs in additional to spaces for indentation, etc. which would be a massive amount of work. It would also be a backward incompatible change in that it would require many third-party extensions to make changes as well. Therefore, it seems to me like the alternative solutions you already listed (third-party extension or manual formatting) would be a better solution. After all, as far as I can tell, this is a need of only a very small minority of our users.
Something that could potentially cause me to reconsider is if you could point to other implementations which already support this. Also, if a third-party extension was created and it became wildly popular, then we might be more inclined to adopt that behavior. However, as it stands now, it appears that this would be a new behavior only implemented by one implementation, which makes it ideal for a third-party extension.
If you'd like, you can use SuperFences to preserve tabs. This accounts for code blocks earlier, before Python Markdown normalizes tabs to spaces. Then you can style them however you want.
Apparently, a third-party extension already exists which implements this. I am closing this.
Description
Python-Markdown currently lacks built-in support for tab customization in code blocks. This feature would allow users to specify the tab width within code blocks, enhancing flexibility and compatibility with various coding standards.
Why is this feature necessary
Different coding standards and preferences exist regarding tab width. By allowing users to customize tab width within code blocks, Python-Markdown can better accommodate these diverse requirements. This feature would improve the accuracy of code representation in Markdown documents, especially when copying code from IDEs or text editors.
Proposed Solution
Alternative Solutions
@daniel-santos
@timabbott
@zulip (zulip/zulip#29044)
Considering Python-Markdown's focus on adhering to Markdown syntax rules, the proposed feature aligns with enhancing the flexibility and usability of the library without deviating from Markdown standards.
The text was updated successfully, but these errors were encountered: