toolness / p5.js-widget

A reusable widget for embedding editable p5 sketches in web pages.
https://toolness.github.io/p5.js-widget/
GNU Lesser General Public License v2.1
162 stars 44 forks source link

auto-format #55

Closed shiffman closed 8 years ago

shiffman commented 8 years ago

This came up at the p5.js working group meeting via @lmccart. Might be good to have "auto-format" with CMD-T in the widget (same as current desktop editor.)

lmccart commented 8 years ago

or just maybe when it is built and rendered at the start, any example code inside is auto-formatted.

toolness commented 8 years ago

Sure!

We can add another option, say, data-auto-format to the widget, that enables auto-formatting, or we could enable it by default and have data-no-auto-format...

toolness commented 8 years ago

Out of curiosity, what's the use case for this? If it's intended primarily for authors, e.g. to workaround issues like #56, then I think there are some alternative solutions... If it's to help learners understand what well-formatted code looks like, though, that's cool!

lmccart commented 8 years ago

this came up from a discussion we had with @tchoi8 where @shiffman and I were mentioning how it's helpful to use proper formatting in teaching examples. @tchoi8 mentioned that it was difficult to format the text in the widget and so we thought an auto-format call before rendering on the page might be helpful.

but looking more closely now at what's happening on the wordpress page, it actually looks ok. if you make the example in another editor and then just copy paste it onto the page, you can take advantage of all tab and auto-format capabilities of the editor you're using. so it might be overkill to build it into the widget.

toolness commented 8 years ago

Ok cool!

Yeah, one can of worms auto-formatting potentially introduces is, "what kind of style should the auto-formatter use?", which I'd love to avoid if at all possible :grin: