Hi,
I am using Wikipedia api https://www.mediawiki.org/wiki/API:Parsing_wikitext#parse to convert wiki text into html.
Everything works fine except that in the output there are also warning messages which are normally seen in preview mode. To exclude them, I set 'preview' parameter to False in the query but warning messages are still in the html output.
Here is an exmaple query: https://en.wikipedia.org/w/api.php?action=parse&format=json&preview=...
Is there any idea how to get html output without preview warning messages.
Thanks a lot, Kenan
The general issue of inline warnings & the need for a saner warning mechanism is discussed at https://phabricator.wikimedia.org/T141970. It seems likely that some code in the infobox you are referencing looks at the REVISION* value, and emits the inline warning if no revision is set.
The easiest way to get rid of the warning would be to heed the warning's advice about the unknown "ethnicity" parameter.
On Wed, Jul 26, 2017 at 8:41 AM, Kenan Erdogan Kenan.Erdogan@gesis.org wrote:
Hi,
I am using Wikipedia api https://www.mediawiki.org/wiki/API:Parsing_wikitext#parse to convert wiki text into html.
Everything works fine except that in the output there are also warning messages which are normally seen in preview mode. To exclude them, I set 'preview' parameter to False in the query but warning messages are still in the html output.
Here is an exmaple query: https://en.wikipedia.org/w/ api.php?action=parse&format=json&preview=False&text=[[foo] ]+{{Infobox%20writer%20|%20name%20%20%20%20%20%20%20% 20%20=%20Test|%20ethnicity%20%20%20%20=%20[[test]]}}
Is there any idea how to get html output without preview warning messages.
Thanks a lot, Kenan
-- GESIS - Leibniz Institute for the Social Sciences Computational Social Science (CSS) Team Social Analytics and Services M.Sc. Kenan Erdogan
Unter Sachsenhausen 6-8, 50667 Cologne, Germany Tel: + 49 (0) 221-47694-211 <+49%20221%2047694211>
Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
The problem here is that the technique used for this (checking is {{REVISIONID}} expands to nothing) really checks for "is this not a saved revision", rather than "is this a preview". In my opinion the entire thing is a bad idea and a huge hack and just asking for problems, like you just discovered. An example using this technique is Template:If preview [1].
You might be able to work around this by using TemplateSandbox [2] features to "replace" problematic templates/modules by ones that do nothing, or "return false". For example, this works for your query by overriding Module:Check for unknown parameters to do nothing [3]:
https://en.wikipedia.org/w/api.php?action=parse&format=json&preview=... (http://tinyurl.com/ycwgyljq)
But this is obviously inconvenient, since you need to manually find out where the output comes from, and would eventually need to implement this for many templates/modules.
[1] https://en.wikipedia.org/wiki/Template:If_preview [2] https://www.mediawiki.org/wiki/Extension:TemplateSandbox [3] https://en.wikipedia.org/wiki/Module:Check_for_unknown_parameters
As a side note, I noticed now that your example query has a "&preview=False" parameter in it – this actually won't do what you expect. Any value given for boolean parameters, including "false", "0", "", etc., means true. If you mean false, you have to not pass the parameter at all. (Not that it changes anything in this case.)
On Wed, Jul 26, 2017 at 5:41 PM, Kenan Erdogan Kenan.Erdogan@gesis.org wrote:
Here is an exmaple query: https://en.wikipedia.org/w/ api.php?action=parse&format=json&preview=False&text=[[foo] ]+{{Infobox%20writer%20|%20name%20%20%20%20%20%20%20% 20%20=%20Test|%20ethnicity%20%20%20%20=%20[[test]]}}
Note that preview=False will actually set the preview parameter to true. See the API doc about datatypes: https://en.wikipedia.org/w/api.php?action=help&modules=main#main.2Fdatat...
mediawiki-api@lists.wikimedia.org