On Sun, Apr 9, 2017 at 11:38 AM, Daniel Kinzler <daniel.kinzler@wikimedia.de
wrote:
Generating wikitext from some other thing is what Scribunto does.
Not really. What Scribunto does is let you run a program to generate wikitext.
If you wanted to write code that took some JSON and turned it into wikitext without going through all the trouble of writing an extension and getting it deployed, you might write that code in Lua as a Scribunto module.
On Mon, Apr 10, 2017 at 12:17 AM, Denny Vrandečić vrandecic@gmail.com wrote:
On Sat, Apr 8, 2017 at 11:30 PM James Hare jamesmhare@gmail.com wrote:
Why, exactly, do you want a wikitext intermediary between your JSON and your HTML? The value of wikitext is that it’s a syntax that is easier to edit than HTML. But if it’s not the native format of your data, nor can browsers render it directly, what’s the point of having it?
Ah, good question indeed. The reason is that users would be actually putting fragments of wikitext into the JSON structure, and then the JSON structure gets assembled into wikitext. Not only would I prefer to have the users work with fragments of wikitext than fragments of HTML, but some things are almost impossible with HTML - e.g. making internal links red or blue depending on the existence of the article, etc.
What you probably want to do then is to extend JsonContent and JsonContentHandler. In the fillParserOutput() method, you'd convert the JSON to wikitext and then pass that wikitext to the Parser; for the latter step you could look at how WikitextContent does it.
You might also look at implementing Content::getWikitextForTransclusion() to let people transclude the resulting wikitext.