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

How to disable some markdown syntax? Indented Code Blocks #181

Open
soylomass opened this issue Apr 15, 2024 · 2 comments
Open

How to disable some markdown syntax? Indented Code Blocks #181

soylomass opened this issue Apr 15, 2024 · 2 comments

Comments

@soylomass
Copy link

Is there any way to disable specific markdown syntax? In my case, I need to disable indented code blocks, leaving only fenced code blocks.
Is it possible?

@soylomass
Copy link
Author

soylomass commented Apr 15, 2024

function disableIndentedCode() {
    const data = this.data();
    add("micromarkExtensions", {
      disable: { null: ["codeIndented"] },
    });

    /**
     * @param {string} field
     * @param {unknown} value
     */
    function add(field, value) {
      const list /** @type {Array<unknown>} */ =
        // Other extensions
        /* c8 ignore next 2 */
        data[field] ? data[field] : (data[field] = []);

      list.push(value);
    }
  }

  const parserOptions = {
    remark: {
      plugins: {
        ["disable-indented-code"]: {
          instance: disableIndentedCode,
        },
      },
    },
  };


    <MDC
      :value="element.text"
      class="markdown-body"
      :parser-options="parserOptions"
    />

Tried with this solution, but it breaks the rendering of the strings where said syntax is included (the whole string is not rendered).
Strings without said syntax are rendered normally.

@farnabaz
Copy link
Collaborator

Disabling core markdown features is out of the module's scope. I suggest creating a discussion in micromark since it is related to micromark.
I'm not sure that you can disable indented code blocks.

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

2 participants