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

open code tag up for extension #967

Open
srenatus opened this issue Mar 4, 2024 · 5 comments
Open

open code tag up for extension #967

srenatus opened this issue Mar 4, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@srenatus
Copy link

srenatus commented Mar 4, 2024

Hello πŸ‘‹

Thanks for Framework, it's been a pleasure to adopt ✨ and I'm planning to keep working with it.

I've been toying with adding Squint as an accepted language (ClojureScript transpiled to JS). My experiment's branch is here, the change is rather light; but it's also roughed in at this point, with some cut corners.

It would be pretty neat if one was able to mix-and-match JS and CLJS in Framework, like

```cljs echo
(defn squint [x]
    (> (:frequency x) 0.06))
```

```js echo
Plot.rectY(alphabet, {
  x: "letter",
  y: "frequency",
  fill: squint,
}).plot()
```

Now, I don't expect Framework to support Squint (although it would be pretty cool). What would be nice, however, would be to open the tags up to customization of some sort. Squint would just be a first example, I could imagine other cool projects getting unlocked by this πŸ’­

I'd be happy to contribute, but I'd need guidance on how to cleanly allow such extensibility in JS.

What do you think?

@srenatus srenatus added the enhancement New feature or request label Mar 4, 2024
@Fil
Copy link
Contributor

Fil commented Mar 4, 2024

Interesting idea! (Note: I took the liberty to edit your message to make the fence code apparent.)

@mbostock
Copy link
Member

mbostock commented Mar 5, 2024

We could allow the project config to register additional code transforms for getLiveSource?

function getLiveSource(content: string, tag: string): string | undefined {
return tag === "js"
? content
: tag === "tex"
? transpileTag(content, "tex.block", true)
: tag === "html"
? transpileTag(content, "html.fragment", true)
: tag === "svg"
? transpileTag(content, "svg.fragment", true)
: tag === "dot"
? transpileTag(content, "dot", false)
: tag === "mermaid"
? transpileTag(content, "await mermaid", false)
: undefined;
}

@srenatus
Copy link
Author

srenatus commented Mar 6, 2024

We could allow the project config to register additional code transforms for getLiveSource?

I think that would be sufficient. Do you want me to just give it a shot? (Is there any precedent in the framework sources, where something additional can be registered?)

@srenatus
Copy link
Author

srenatus commented Mar 8, 2024

Given SQL tags have landed (πŸŽ‰), PRQL tags could also be nice and done with this.

@mbostock
Copy link
Member

@srenatus Tracking PRQL separately with #1075; some progress in #1078.

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

No branches or pull requests

3 participants