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

Finalize syntax (e.g., ```js {show}) to denote live code blocks #28

Closed
mbostock opened this issue Oct 18, 2023 · 4 comments · Fixed by #75
Closed

Finalize syntax (e.g., ```js {show}) to denote live code blocks #28

mbostock opened this issue Oct 18, 2023 · 4 comments · Fixed by #75
Assignees
Labels
enhancement New feature or request

Comments

@mbostock
Copy link
Member

We currently use standard fenced code blocks

```js
1 + 2
```

This can be surprising because it behaves differently from standard Markdown: the code runs instead of being displayed! And also it’s inconsistent with non-JavaScript code blocks, which do display as normal.

So instead, we could follow Quarto’s example by using curly braces:

```{js}
1 + 2
```

I also thought about using script tags, or some such…

<script type="observable">
1 + 2
</script>

But that seems weird. 🤔

@mbostock mbostock added the enhancement New feature or request label Oct 18, 2023
@mbostock
Copy link
Member Author

Another option would be markdown-it-container, which might look like this:

:::js
1 + 2
:::

@mootari
Copy link
Member

mootari commented Oct 24, 2023

Curly braces seem like the safest choice to me, not only because they follow Quarto's style but also because code blocks would still display as code (albeit without the correct highlighting) when viewing the Markdown files directly.

@wiltsecarpenter wiltsecarpenter self-assigned this Oct 26, 2023
@wiltsecarpenter wiltsecarpenter linked a pull request Oct 30, 2023 that will close this issue
@mbostock mbostock changed the title Use curly braces (e.g., {js}) to denote live code blocks Finalize syntax (e.g., ```js {show}) to denote live code blocks Nov 13, 2023
@mbostock mbostock added this to the Internal milestone Nov 13, 2023
@mbostock mbostock assigned mbostock and unassigned wiltsecarpenter Nov 13, 2023
@cinxmo
Copy link
Contributor

cinxmo commented Nov 14, 2023

Does this ticket include which options we will support for Milestone 1: Internal Release?

@mbostock
Copy link
Member Author

They’re not currently called out, but I believe all we need to support is:

  • echo - whether to echo the code into the page with nice syntax highlighting; defaults to false if evaluate is true, and true if evaluate is false
  • evaluate - whether to run the code; defaults to true
  • display - whether to implicitly display the value for expression fenced code blocks, and/or whether to suppress the output from calls to display

The names above aren’t finalized, but I think that’s all the functionality we need. (Plus the ability to control at the page level via front matter but that is tracked separately.)

@Fil Fil mentioned this issue Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants