Thanks, this sounds more like what I was hoping to try. I think I
understand how I would use that after retrieving a page's contents. What
would I use after modifying the DOM to convert it back to wikitext?
On Mon, Aug 14, 2017 at 7:17 PM, Thomas PT <thomaspt(a)hotmail.fr> wrote:
An other option that does not relies on anything else
than MediaWiki core
is to use the MediaWiki preprocessor. You do
$wgParser->getPreprocessor->preprocessToDom(
'my wikitext' ); and you get a DOM document that contains the template call
formatted in an XML tree. It will looks like:
<template>
<title>Beer</title>
<part>
<name>Name</name>
<value>Rocket Fuel</value>
</part>
<part>
...
</part>
...
</template>
Cheers,
Thomas
Le 14 août 2017 à 16:47, Daren Welsh
<darenwelsh(a)gmail.com> a écrit :
Thanks for the responses. I was hoping there would be some php function
in
MW core or some API feature that I could use like
from [0]. I'm having a
hard time understanding how I would use either of these suggestions.
[0]
https://doc.wikimedia.org/mediawiki-core/master/php/
On Wed, Aug 9, 2017 at 3:02 PM, Gergo Tisza <gtisza(a)wikimedia.org>
wrote:
> mwparserfromhell (
https://github.com/earwig/mwparserfromhell ) is also
> pretty good at this kind of thing.
>
> On Wed, Aug 9, 2017 at 6:30 PM, Subramanya Sastry <
ssastry(a)wikimedia.org>
> wrote:
>
>> Take a look at Parsoid's output spec and the Parsoid API (as exposed
>> through the REST API).
>>
>> See
https://www.mediawiki.org/wiki/Specs/HTML/1.4.0#Template_markup and
>>
https://en.wikipedia.org/api/rest_v1/#!/Transforms/post_tran
>> sform_html_to_wikitext_title_revision
>>
>> So, you fetch the HTML, edit data-mw blob, and save it back.
>>
>> Subbu.
>>
>>
>>
>> On 08/09/2017 10:22 AM, Daren Welsh wrote:
>>
>>> I'm working on a server-side script that will periodically revise wiki
>>> pages that all use the same template. Is there a function I can use
that
>>> will parse a page and then find and
replace template arguments with
> values
>>> I determine within my script?
>>>
>>> For example, let's say I have Template:Beer like the following:
>>>
>>> {{Beer
>>> |Name=
>>> |Brewery=
>>> |Style=
>>> |ABV=
>>> |IBU=
>>> }}
>>>
>>> So if I had a page Rocket Fuel:
>>>
>>> {{Beer
>>> |Name=Rocket Fuel
>>> |Brewery=8th Wonder
>>> |Style=Vietnamese Coffee Porter
>>> |ABV=4.6
>>> |IBU=18
>>> }}
>>>
>>> Let's say my script "discovered" an error in one of the
arguments and
>>> needed to update the page. For example, let's say the IBU was actually
> 28.
>>> Is there a function that will find and replace the value for IBU in
the
> page?
>
> I'm currently using regex, but I'm wondering if there's a more
trustworthy
> method.
>
> Thanks,
>
> Daren
> _______________________________________________
> Wikitech-l mailing list
> Wikitech-l(a)lists.wikimedia.org
>
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>
_______________________________________________
Wikitech-l mailing list
Wikitech-l(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
_______________________________________________
Wikitech-l mailing list
Wikitech-l(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
--
__________________
http://enterprisemediawiki.org
http://mixcloud.com/darenwelsh
_______________________________________________
Wikitech-l mailing list
Wikitech-l(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
_______________________________________________
Wikitech-l mailing list
Wikitech-l(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l