More related functionality: Parsoid supports JSON as a contenttype, and emits a special type of table (the same as the HTML table generated by the HTML handler for JSON in mediawiki). You can edit this in VE, although w/o any special support, and Parsoid will serialize it back to JSON.
This could be turned into a very pleasant type-aware editor for JSON in VE pretty easily. --scott On Sun, Apr 9, 2017 at 2:23 AM, Denny Vrandečić <[email protected]> wrote: > Here's my requirement: > - a wiki page is one JSON document > - when editing, the user edits the JSON directly > - when viewing, I have a viewer that turns the JSON into wikitext, and that > wikitext gets rendered as wikitext and turned into HTML by MediaWiki > > I have several options, including: > > 1) hook for a tag like <json>, and write an extension that parses the > content between the tags and turns it into wikitext (not ideal, as I don't > use any of the existing support for JSON stuff, and also I could have > several such tags per page, which does not fit with my requirements) > > 2) I found the JsonConfig extension by yurik. This allows me to do almost > all of the things above - but it returns HTML directly, not wikitext. It > doesn't seem trivial to be able to return wikitext instead of HTML, but > hopefully I am wrong? Also, this ties in nicely with the Code Editor. > > 3) there is actually a JsonContentHandler in core. But looking through it > it seems that this suffers from the same limitations - I can return HTML, > but not wikitext. > > 3 seems to have the advantage to be more actively worked on that 2 (which > is not based on 3, probably because it is older than 3). So future goodies > like a Json Schema validator will probably go to 3, but not to 2, so I > should probably go to 3. > > Writing this down, one solution could be to create the wikitext, and then > call the wikitext parser manually and have it create HTML? > > I have already developed the extension in 1, and then fully rewritten it in > 2. Before I go and rewrite it again in 3, I wanted to ask whether I am > doing it right, or if should do it completely differently, and also if > there are examples of stuff developed in 3, i.e. of extensions or features > using the JsonContent class. > > Example: > I have a JSON document > { "username": "Denny" } > which gets turned into wikitext > ''Hello, [[User:Denny|Denny]]!'' > which then gets turned into the right HTML and displayed to the user, e.g. > <i>Hello, <a href="...">Denny</a>!</i> > > Cheers, > Denny > _______________________________________________ > Wikitech-l mailing list > [email protected] > https://lists.wikimedia.org/mailman/listinfo/wikitech-l -- (http://cscott.net) _______________________________________________ Wikitech-l mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikitech-l
