jgm / djot-playground

Playground for the djot light markup language
https://djot.net/playground/
6 stars 2 forks source link

Bug: empty code block breaks the playground #4

Closed waldyrious closed 2 years ago

waldyrious commented 2 years ago

I tried entering a code block by typing the delimiters first:

and then adding the content within:

test

...but this broke the playground, which became unresponsive. The console error is this:

Click to expand ``` Uncaught (in promise) Error: ./djot/html.lua:63: bad argument #1 to 'find' (string expected, got nil) assertOk https://djot.net/playground/assets/index.3c860766.js:1 b https://djot.net/playground/assets/index.3c860766.js:1 p https://djot.net/playground/assets/index.3c860766.js:43 p https://djot.net/playground/assets/index.3c860766.js:43 er https://djot.net/playground/assets/index.3c860766.js:1 p https://djot.net/playground/assets/index.3c860766.js:45 Qn https://djot.net/playground/assets/index.3c860766.js:1 Vt https://djot.net/playground/assets/index.3c860766.js:1 promise callback*Kn https://djot.net/playground/assets/index.3c860766.js:1 nr https://djot.net/playground/assets/index.3c860766.js:1 ctx https://djot.net/playground/assets/index.3c860766.js:1 B https://djot.net/playground/assets/index.3c860766.js:60 dt https://djot.net/playground/assets/index.3c860766.js:1 m https://djot.net/playground/assets/index.3c860766.js:45 bn https://djot.net/playground/assets/index.3c860766.js:1 vn https://djot.net/playground/assets/index.3c860766.js:1 Er https://djot.net/playground/assets/index.3c860766.js:60 https://djot.net/playground/assets/index.3c860766.js:60 ``` [index.3c860766.js:1:12901](https://djot.net/playground/assets/index.3c860766.js)

Note: this doesn't happen if I type the code block line by line (opening delimiters, content, closing delimiters)

jgm commented 2 years ago

It's not a bug in the playground, but a bug in the parser. You can reproduce it with plain djot.

waldyrious commented 2 years ago

Ah, thanks for the clarification. Can you move this issue to the main repository, or should I report a new issue there?

jgm commented 2 years ago

Fixed in 4246252b16a988ad9473b810c10a2036d768cdb6

waldyrious commented 2 years ago

That was fast! :smile:

For convenience, here's a linked reference to the commmit: https://github.com/jgm/djot/commit/4246252b16a988ad9473b810c10a2036d768cdb6