Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabling the "code" rule doesn't disable code parsing, just code rendering #1014

Open
silvester-pari opened this issue Mar 4, 2024 · 0 comments

Comments

@silvester-pari
Copy link

silvester-pari commented Mar 4, 2024

When disabling the code rule, the default seems to be rendering a paragraph, no matter what the content is.

Setup

const md = markdownit();
md.disable('code')
# This renders a heading

  # This also renders a heading

    # This renders a paragraph instead of a heading

Output

<h1>This renders a heading</h1>
<h1>This also renders a heading</h1>
<p># This renders a paragraph instead of a heading</p>

This is because in the other rules there is also a "code block check", e.g. https://github.com/markdown-it/markdown-it/blob/master/lib/rules_block/heading.mjs#L10

  // if it's indented more than 3 spaces, it should be a code block
  if (state.sCount[startLine] - state.blkIndent >= 4) { return false }

Question / Bug description

If I understand correctly, disabling the code rule just disables rendering of the code block, but not the code block parsing logic. Similar to the case with 2 spaces, I propose that disabling the code rule should skip the code block parsing in all other rules.

Background:

Might be connected to #936

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

No branches or pull requests

1 participant