Embedding error if any cell of the notebook is named with a dash

Hi! just a very silly thing, but in case it is useful to mention it. I was having troubles embedding any cell from a notebook and I didn’t know why until I discovered it was related to a different cell that I had named with a “dash” in the name (as test-01 for example).

If you try to do that in a JavaScript cell, you got a SyntaxError error. But if you do it in a Markdown one, no error appears. Everything looks fine until you get to the embedding menu and select any cell from the notebook. You see something is wrong because the preview is blank and the code doesn’t work afterwards neither.

I have realised the cause thanks to the error in the console:

Here is an example, where the name of the first cell causes that error if you try to embed the second one: Title (cell named with "-") / Carmen Torrecillas | Observable

Thanks!!

1 Like

Ah yeah we were just talking about this the other day. You can currently give cells names (using the GUI toolbar) that are invalid JavaScript identifiers, meaning they can’t be embedded or otherwise referenced. This is a bug; we should force the names to be valid. We have an issue filed internally, and I’ve added a note pointing to your example. Thanks Carmen. :pray:

2 Likes

Great, thanks to you! :slightly_smiling_face:

There’s also Names entered into the cell toolbar are not validated · Issue #423 · observablehq/feedback · GitHub which was created as a bug report, but has for some strange reason been labeled as a feature request.