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

Elixir code snippets containing a tuple inside another tuple cause the CLI to crash #1316

Closed
John-Goff opened this issue Feb 20, 2024 · 0 comments · Fixed by #1317
Closed
Assignees
Labels
bug Something isn't working

Comments

@John-Goff
Copy link

John-Goff commented Feb 20, 2024

Describe the bug
Elixir code snippets containing a tuple ({}) with two elements, where the first element is another tuple, cause the slidev CLI to crash with the following error:

4:21:35 p.m. [vite] Internal server error: Interpolation end sign was not found.
  Plugin: vite:vue
  File: /@slidev/slides/1.md:4:280
  2  |  <InjectedLayout v-bind="frontmatter">
  3  |  <CodeBlockWrapper v-bind="{}" :ranges='[""]'>
  4  |  <pre class="shiki shiki-themes vitesse-dark vitesse-light slidev-code" style="--shiki-dark:#dbd7caee;--shiki-light:#393a34;--shiki-dark-bg:#121212;--shiki-light-bg:#ffffff"><code class="language-elixir"><span class="line"><span style="--shiki-dark:#666666;--shiki-light:#999999">{{},</span><span style="--shiki-dark:#4C9A91;--shiki-light:#2F798A"> 1</span><span style="--shiki-dark:#666666;--shiki-light:#999999">}</span></span></code></pre>
     |                                                                                                                                                                                                                                                                                          ^
  5  |  </CodeBlockWrapper>
  6  |  </InjectedLayout>
      at createCompilerError (/Users/johngoff/Repos/presentations/lfe-for-elixir-programmers/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:1332:17)
      at emitError (/Users/johngoff/Repos/presentations/lfe-for-elixir-programmers/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:2825:5)
      at Object.onend (/Users/johngoff/Repos/presentations/lfe-for-elixir-programmers/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:2391:11)
      at Tokenizer.finish (/Users/johngoff/Repos/presentations/lfe-for-elixir-programmers/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:1199:14)
      at Tokenizer.parse (/Users/johngoff/Repos/presentations/lfe-for-elixir-programmers/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:1177:10)
      at Object.baseParse (/Users/johngoff/Repos/presentations/lfe-for-elixir-programmers/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:2864:13)
      at Object.parse (/Users/johngoff/Repos/presentations/lfe-for-elixir-programmers/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.js:703:23)
      at Object.parse$2 [as parse] (/Users/johngoff/Repos/presentations/lfe-for-elixir-programmers/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:1851:24)
      at createDescriptor (file:///Users/johngoff/Repos/presentations/lfe-for-elixir-programmers/node_modules/@vitejs/plugin-vue/dist/index.mjs:74:43)
      at transformMain (file:///Users/johngoff/Repos/presentations/lfe-for-elixir-programmers/node_modules/@vitejs/plugin-vue/dist/index.mjs:2367:34)

To Reproduce
Steps to reproduce the behavior:

  1. Create a slides.md file with the following contents
```elixir
{{}, 1}
```
  1. Start slidev with npm run dev
  2. See the error in the terminal

This issue came about because I want to include a snippet of Elixir AST in my talk, this is the code from my slide. I tried to shrink it to the most minimally reproducing example I could, which is what you see above.

iex(5)> quote do: :io.fwrite(~c"~s" ++ ~c"~n", [~c"Hello world!"])
{{:., [], [:io, :fwrite]}, [],
 [
   {:++, [context: Elixir, imports: [{2, Kernel}]],
    [
      {:sigil_c, [delimiter: "\"", context: Elixir, imports: [{2, Kernel}]],
       [{:<<>>, [], ["~s"]}, []]},
      {:sigil_c, [delimiter: "\"", context: Elixir, imports: [{2, Kernel}]],
       [{:<<>>, [], ["~n"]}, []]}
    ]},
   [
     {:sigil_c, [delimiter: "\"", context: Elixir, imports: [{2, Kernel}]],
      [{:<<>>, [], ["Hello world!"]}, []]}
   ]
 ]}

The issue is also reproducible with the following snippets of elixir code

{{nil}, 1}
{{:a}, 1}
{{}, ""}

So it seems to me that any valid elixir value can be the second argument of the tuple, and the first tuple can or can not have values and the issue still persists.

I believe this is due to incompatibilities with the Vue template syntax, but I expect that inside my codeblocks I can have valid code without issues. Please let me know if there's some escaping I should be doing that I'm not doing, this is my first presentation with slidev.

Desktop (please complete the following information):

  • OS: MacOS 14.2.1 (23C71)
  • Browser: Firefox 122.0.1 (64-bit)
  • Slidev version:
    "@slidev/cli": "^0.48.0-beta.3",
    "@slidev/theme-default": "latest",
    "@slidev/theme-seriph": "latest",
    "vue": "^3.4.19"
  • Node Version: v20.9.0
@KermanX KermanX added the bug Something isn't working label Feb 21, 2024
@KermanX KermanX self-assigned this Feb 21, 2024
KermanX added a commit to KermanX/slidev that referenced this issue Feb 21, 2024
antfu pushed a commit that referenced this issue Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants