observablehq / framework

A static site generator for data apps, dashboards, reports, and more. Observable Framework combines JavaScript on the front-end for interactive graphics with any language on the back-end for data analysis.
https://observablehq.com/framework/
ISC License
2.13k stars 85 forks source link

inline tokenizer, take two #1441

Closed mbostock closed 3 weeks ago

mbostock commented 3 weeks ago

Re-applies #1425, but without trying to change Markdown tokenization. Inline expressions must still be within blocks, but we at least now parse them correctly within the block.

Fixes #375. Fixes #396 (by considering it intended). Fixes #636.

mbostock commented 3 weeks ago

So this still doesn’t work (by design, because Markdown):

${html`<div>
  ${[1, 2, 3].map((i) => i)}
</div>`}

But you can easily fix it by putting it inside an HTML block:

<div>
  ${html`<div>
    ${[1, 2, 3].map((i) => i)}
  </div>`}
</div>