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

Build error or warning when using non-supported custom container #4428

Open
4 tasks done
o-l-a-v opened this issue Dec 16, 2024 · 2 comments
Open
4 tasks done

Build error or warning when using non-supported custom container #4428

o-l-a-v opened this issue Dec 16, 2024 · 2 comments
Labels
build Related to the build system enhancement New feature or request

Comments

@o-l-a-v
Copy link

o-l-a-v commented Dec 16, 2024

Is your feature request related to a problem? Please describe.

Build does not error or warn when a user wrongfully uses a non-supported custom container ( https://vitepress.dev/guide/markdown#custom-containers ), like ::: NOTE, ref:

Current behavior is just to build with no warning or error, which makes it harder to catch issues like this:

image

Describe the solution you'd like

Error or warn when using a non-supported custom container.

Describe alternatives you've considered

No response

Additional context

No response

Validations

@o-l-a-v
Copy link
Author

o-l-a-v commented Dec 30, 2024

One more example that could've been caught during build: jdx/mise#3876

Sh code block used:

:::sh
<code>
:::

Should've been:

```sh
<code>
```

@brc-dd brc-dd added enhancement New feature or request build Related to the build system labels Dec 30, 2024
@brc-dd
Copy link
Member

brc-dd commented Dec 30, 2024

As a workaround, you can add something like this:

import { defineConfig } from 'vitepress';
import mditContainer from 'markdown-it-container';

export default defineConfig({
  markdown: {
    config(md) {
      mditContainer(md, '_', {
        validate(params) {
          params = params.trim();
          if (params)
            console.warn(
              `\n\x1b[33mUnknown markdown container - ${params}\x1b[0m`
            );
          return false;
        },
      });
    },
  },
});

It won't show you the file name / line number though.

https://stackblitz.com/edit/vite-yhmisdwk?file=docs/.vitepress/config.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Related to the build system enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants