Hi,
Is it possible through the API to give it some wikitext and get in return the same wikitext where {{subst:}} and {{safesubst:}} have been replaced, as they would be when saving an edit ?
In WPCleaner https://en.wikipedia.org/wiki/Wikipedia:WPCleaner, I want to be able to insert things like current date, so I'm currently inserting things like {{safesubst:CURRENTMONTHNAME}} but as they don't work inside <ref> tags, I'd prefer to expand then myself rather than relying on the action=edit to do it.
Nico
On Sat, Sep 19, 2015 at 7:09 AM, Nicolas Vervelle nvervelle@gmail.com wrote:
Is it possible through the API to give it some wikitext and get in return the same wikitext where {{subst:}} and {{safesubst:}} have been replaced, as they would be when saving an edit ?
Use action=parse with onlypst=1.
On Sat, Sep 19, 2015 at 4:41 PM, Brad Jorsch (Anomie) <bjorsch@wikimedia.org
wrote:
On Sat, Sep 19, 2015 at 7:09 AM, Nicolas Vervelle nvervelle@gmail.com wrote:
Is it possible through the API to give it some wikitext and get in return the same wikitext where {{subst:}} and {{safesubst:}} have been replaced, as they would be when saving an edit ?
Use action=parse with onlypst=1.
Thanks Brad !
It almost works as I want, but there's just one thing that doesn't work as I expected: sometimes, the text that I give to the API ends with a new line, but in the result that new line is removed. Is it normal ? Is there a way around this ?
Nico
On Sat, Sep 19, 2015 at 1:37 PM, Nicolas Vervelle nvervelle@gmail.com wrote:
sometimes, the text that I give to the API ends with a new line, but in the result that new line is removed. Is it normal ? Is there a way around this ?
Yes, it's normal. The workaround is to handle any trailing whitespace you need preserved yourself instead of passing it through the parser.
On Sun, Sep 20, 2015 at 1:50 PM, Brad Jorsch (Anomie) <bjorsch@wikimedia.org
wrote:
On Sat, Sep 19, 2015 at 1:37 PM, Nicolas Vervelle nvervelle@gmail.com wrote:
sometimes, the text that I give to the API ends with a new line, but in the result that new line is removed. Is it normal ? Is there a way around this ?
Yes, it's normal. The workaround is to handle any trailing whitespace you need preserved yourself instead of passing it through the parser.
Thanks a lot ! That's what I ended up doing ;-)
mediawiki-api@lists.wikimedia.org