Summary:
Originally, the query service UI loaded the example via Parsoid, which meant that examples could not be loaded from wikis without a VisualEditor/Parsoid set up. This severely limited the usefulness of the query service on third-party installations.
This was ultimately resolved in I46420935e5. The following approaches were explored:
- The original approach, to ask Parsoid for the HTML of the page (which, unlike the legacy Parser’s output, includes annotations for each template invocation and argument), and extract the query arguments of all SPARQL and SPARQL2 transclusions. Doesn’t work for most third-party installs.
- Parse wikitext, looking for {{SPARQL}} and {{SPARQL2}} transclusions and their preceding headings. Fragile.
- Model query examples as structured data (e. g. in Wikidata statements). Didn’t go anywhere.
- Use the parse tree of the wikitext. Looked promising, ultimately wasn’t implemented.
- Use the parsed HTML from the legacy parser, extracting the contents of any <syntaxhighlight> block and finding the preceding headings similarly to the Parsoid version. Implemented and deployed.