Last modified: 2014-10-30 18:39:06 UTC
Copied from my Russian Wikipedia talk page: https://ru.wikipedia.org/wiki/%D0%9E%D0%B1%D1%81%D1%83%D0%B6%D0%B4%D0%B5%D0%BD%D0%B8%D0%B5_%D1%83%D1%87%D0%B0%D1%81%D1%82%D0%BD%D0%B8%D0%BA%D0%B0:Keegan_(WMF)#Bug_report_11 I filled TemplateData for Шаблон:Малая планета early, template with comments inserted in articles {{Малая планета <!-- Основной блок --> | param = <!-- Орбитальные характеристики --> | param = <!-- Физические характеристики --> | param = }} now if i deleted comments https://ru.wikipedia.org/w/index.php?title=(87)_Сильвия&diff=64040824&oldid=62184664 then i can see parameters in VE editor but if comments still in text then VE editor for template staying on "Загрузка..." ("Load...") and don't show parameters. sample: (25143) Итокава Sunpriat 08:40, 6 июля 2014 (UTC)
Hm.. it sounds like the bug report says that html comments inside TemplateData conflict with VisualEditor. However I think this might've been a confusion in translation. I think the reported problem is that when the wikitext has html comments in the transclusion, that Parsoid/VE is including those as part of the template name. E.g. that when invoking: {{ Echo | 1 <!-- One --> = Foo }} That the transclusion dialog and/or Parsoid is saying there is a parameter called "! <!-- One -->", and renders that as actual text in the label for the UI. Rephrasing bug accordingly. I think this is something that should be normalised by Parsoid as VisualEditor shouldn't need to know what html comments mean in wikitext.
Created attachment 15885 [details] Screenshot of bug. Screenshot for editing the following on on https://www.mediawiki.org/wiki/VisualEditor/Basic_example_worksheet?veaction=edit {{Wikimedia engineering project information | name =VisualEditor<!-- This HTML comment should not get deleted or modified. --> | description <!-- ignored comment describing the parameter -->= Creating a visual editor for MediaWiki, other platforms and the Web at large | logo =VisualEditor-logo.svg | .. }}
For comparison, Parsoid already strips out html comments from the template title. It should do so for parameter names as well (in addition to trimming whitespace).
So… this is asking if Parsoid would consider making the 'params' block of their API give a 'normalised' version of the parameter name, possibly with a 'target' version as well like they do with templates' names? E.g.: Wikitext > {{ec<!--Ho-->ho<!--Ha!-->|1<!--Foo!-->2=Foo}} Current Parsoid output: > { > 'parts': [ { > 'template': { > 'target': { > 'wt': 'ec<!--Ho-->ho<!--Ha!-->', > 'href': '../Template:Echo' > }, > 'params': > { > '1<!--Foo!-->2': { > 'wt': 'Foo' > } > }, > 'i': 0 > } > } ] > }> Requested Parsoid output: > { > 'parts': [ { > 'template': { > 'target': { > 'wt': 'ec<!--Ho-->ho<!--Ha!-->', > 'href': '../Template:Echo' > }, > 'params': > { > '12': { > 'target': '1<!--Foo!-->2', > 'wt': 'Foo' > } > }, > 'i': 0 > } > } ] > } … or similar?
Change 169732 had a related patch set uploaded by Marcoil: Bug 67657: Add normalized param names to templates https://gerrit.wikimedia.org/r/169732
In the patch I've uploaded, the normalized parameter name is used as the entry for the parameter info and the original parameter wikitext only appears if different, in the 'paramWt' attribute. So James' example would output as > { > 'parts': [ { > 'template': { > 'target': { > 'wt': 'ec<!--Ho-->ho<!--Ha!-->', > 'href': '../Template:Echo' > }, > 'params': > { > '12': { > 'paramWt': '1<!--Foo!-->2', > 'wt': 'Foo' > } > }, > 'i': 0 > } > } ] > } Will that be enough, or should the paramWt be included for each parameter? Most of them will be the same anyway and that would increase page size a lot…
This looks fine to me. We don't really need paramWt in VE anyway, we don't really care that there was a comment in there, as long as Parsoid can preserve it when the template is edited. So with your proposed change, we wouldn't even have to change anything, because we'd just ignore (and preserve) paramWt.
I'm not a fan of making 'wt' return something that's not the original wikitext. How will the need for a normalized name evolve with the 'html' parameter format? It's relatively straightforward to ask for .textContent.
Gabriel, 'wt' still contains the original wikitext for the parameter value as it's always done, we're just adding a new paramWt attribute that only shows up if the original parameter name wikitext is different from the actual parameter name that would be used in expansion. I think the example was a little confusing because the comment in the param name is the same as the param value, sorry for that. Another example, this time with html in it too: > {{ec<!--tpl comment-->ho|unnamed param value|1<!--param name comment-->2=Param ''value''}} > { > 'parts': [ { > 'template': { > 'target': { > 'wt': 'ec<!--tpl comment-->ho', > 'href': '../Template:Echo' > }, > 'params': > { > '1': { > 'wt': "unnamed param value", > 'html': 'unnamed param value' > } > }, > { > '12': { > 'paramWt': '1<!--param name comment-->2', > 'wt': "Param ''value''", > 'html': 'Param <i>value</i>' > } > }, > 'i': 0 > } > } ] > } If paramWt isn't actually needed by VE, maybe we could even not output it at all in data-mw, as it's also kept in data-parsoid…
Marc, thanks for the clarification. I think the name 'paramWT' contributed to my confusion. It sounds more like the value to me. How about 'key.wt'? That could be extended with key.html etc in the future. We should definitely include the wikitext for the key, as there is no good way to properly handle editing otherwise. VE shouldn't just pretend that a parameter was not templated, when it was. Those comments also often contain information that the user might be interested in.
Change 169732 merged by jenkins-bot: Bug 67657: Add normalized parameter names to templates https://gerrit.wikimedia.org/r/169732