Add the ability to specify options on the demo page as JSON#1357
Add the ability to specify options on the demo page as JSON#1357styfle merged 8 commits intomarkedjs:masterfrom
Conversation
|
I can do that, although right now all the things on the right are output/read-only, while the left side is input. What if instead of the details toggle, I added a similar dropdown on the input side? (Example of what it looks like forthcoming.) |
|
How about this change? Now all input is on the left, all output is on the right, and both have parallel type selectors. |
|
(FWIW, you can look at the live version at https://aprotim.github.io/marked/demo/) |
|
This is awesome! When the page loads the first time and there are no options in the query string, can you do This will give people an idea of what options are available 👍 |
Per @styfle's suggestion, setting the options element's contents to the defaults on load.
Done! |
|
@aprotim looks like your demo page has an error seems to be because the options are duplicated in the "renderer" option |
|
Ah, yeah. This is a problem with the roundtrip through JSON, when the default value for "renderer" is a complex object, not a dumb data object. I can either remove renderer from the object before stringifying, or I can set the default options text to be some manually-curated subset... let me tinker with it for a sec. |
|
Ok, now we filter any complex objects (or at least any objects whose prototype is different than Object's) out when we stringify. Seems to have cleared up the problem. |
styfle
left a comment
There was a problem hiding this comment.
This is a much needed feature, thank you! 🎉

Description
Create a details toggle that hides a textarea into which a user can type a JSON-formatted options object.
(For some reason, I can't seem to get the textarea inside a details tag to match the width of the other textareas. After staring at the CSS and banging my head against it, I figured I'd let other people look at it, decide if it was important, and if it was, how to fix it.)
Contributor
Committer
In most cases, this should be a different person than the contributor.