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

Compilation errors occur in some special cases #449

Closed
keuby opened this issue Nov 22, 2021 · 6 comments
Closed

Compilation errors occur in some special cases #449

keuby opened this issue Nov 22, 2021 · 6 comments
Labels
bug Something isn't working
Milestone

Comments

@keuby
Copy link

keuby commented Nov 22, 2021

Describe the bug

The MD content contains the following code build error

## Properties

| Property | Type                                 |
| -------- | ------------------------------------ |
| icon     | { active: string; default: string; } |
yarn run v1.22.11
$ vitepress build docs
vitepress v0.20.0
⠋ building client + server bundles...[vite:vue] Duplicate attribute.
file: /vitepress-bug-demo/docs/index.md:5:42
✖ building client + server bundles...
[vite:vue] Cannot read property 'line' of undefined
file: /vitepress-bug-demo/docs/index.md
build error:
 SyntaxError: Duplicate attribute.
    at createCompilerError (/vitepress-bug-demo/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:19:19)
    at emitError (/vitepress-bug-demo/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:1599:29)
    at parseAttribute (/vitepress-bug-demo/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:1340:9)
    at parseAttributes (/vitepress-bug-demo/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:1316:22)
    at parseTag (/vitepress-bug-demo/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:1186:17)
    at parseElement (/vitepress-bug-demo/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:1115:21)
    at parseChildren (/vitepress-bug-demo/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:943:28)
    at parseElement (/vitepress-bug-demo/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:1131:22)
    at parseChildren (/vitepress-bug-demo/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:943:28)
    at parseElement (/vitepress-bug-demo/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:1131:22) {
  code: 'PLUGIN_ERROR',
  loc: {
    file: '/vitepress-bug-demo/docs/index.md',
    line: 5,
    column: 42
  },
  id: '/vitepress-bug-demo/docs/index.md',
  plugin: 'vue',
  hook: 'transform',
  pluginCode: 2,
  watchFiles: [
    '/vitepress-bug-demo/node_modules/vitepress/dist/client/app/index.js',
    '/vitepress-bug-demo/docs/index.md',
    '/vitepress-bug-demo/node_modules/vitepress/dist/client/app/utils.js',
    '/vitepress-bug-demo/node_modules/vitepress/dist/client/app/router.js',
    '/vitepress-bug-demo/node_modules/vitepress/dist/client/app/data.js',
    '/vitepress-bug-demo/node_modules/vitepress/dist/client/app/composables/head.js',
    '/vitepress-bug-demo/node_modules/vitepress/dist/client/app/composables/preFetch.js',
    '/vitepress-bug-demo/node_modules/vitepress/dist/client/app/components/Content.js',
    '/vitepress-bug-demo/node_modules/vitepress/dist/client/app/components/ClientOnly.js',
    '/vitepress-bug-demo/node_modules/vitepress/dist/client/app/components/Debug.vue',
    '/vitepress-bug-demo/node_modules/vue/dist/vue.runtime.esm-bundler.js',
    '/vitepress-bug-demo/node_modules/vitepress/dist/client/theme-default/index.js'
  ]
}

Reproduction

https://github.com/keuby/vitepress-bug-demo.git

Expected behavior

Build does not report errors

System Info

System:
    OS: macOS 11.6
    CPU: (8) arm64 Apple M1
    Memory: 121.91 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.17.6 - ~/.nvm/versions/node/v14.17.6/bin/node
    Yarn: 1.22.11 - ~/.nvm/versions/node/v14.17.6/bin/yarn
    npm: 6.14.15 - ~/.nvm/versions/node/v14.17.6/bin/npm
  Browsers:
    Chrome: 96.0.4664.55
    Edge: 95.0.1020.53
    Firefox: 90.0
    Safari: 15.0
  npmPackages:
    vitepress: ^0.20.0 => 0.20.0 


### Additional context

_No response_

### Validations

- [X] Follow our [Code of Conduct](https://vuejs.org/coc)
- [X] Read the [docs](https://vitepress.vuejs.org/).
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
@keuby keuby added the bug: pending triage Maybe a bug, waiting for confirmation label Nov 22, 2021
@keuby
Copy link
Author

keuby commented Nov 22, 2021

The above content will be compiled like this

  <tr>
      <td>icon</td>
      <td active:="" string;="" default:="" string;=""></td>
  </tr>

@norskeld
Copy link

norskeld commented Dec 1, 2021

Not sure about the reason (I think it's related to interpolation in Markdown files, but you can easily workaround this by enclosing this piece { active: string; default: string; } in backticks, so it's treated like an inline code block.

This compiles just fine:

## Properties

| Property | Type                                   |
| -------- | -------------------------------------- |
| icon     | `{ active: string; default: string; }` |

@keuby
Copy link
Author

keuby commented Dec 3, 2021

Not sure about the reason (I think it's related to interpolation in Markdown files, but you can easily workaround this by enclosing this piece { active: string; default: string; } in backticks, so it's treated like an inline code block.

This compiles just fine:

## Properties

| Property | Type                                   |
| -------- | -------------------------------------- |
| icon     | `{ active: string; default: string; }` |

But the content is automatically generated by the @microsoft/api-documenter

@kiaking kiaking added bug Something isn't working and removed bug: pending triage Maybe a bug, waiting for confirmation labels May 23, 2022
@kiaking
Copy link
Member

kiaking commented May 23, 2022

Confirmed. Not sure how to fix, but we wanna fix.

@kiaking kiaking added this to the v1.0.0 milestone May 27, 2022
@brc-dd
Copy link
Member

brc-dd commented May 28, 2022

Can now be done by disabling markdown-it-attrs. Ref. #664

Output:

image

@kiaking
Copy link
Member

kiaking commented May 29, 2022

Niice! Thanks for the confirmation 🙌 🙌 🙌 I think disabling attrs plugin is only logical way to go around this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants