That only works on the content of an entire page, doesn't it?  I've just got a short snippet of wikitext that I've already parsed out of a page.  Specifically, a proposed DYK hook, such as:

that '''[[Edward A. Hanna]]''' wanted to eliminate the [[New York State Assembly]] while he served in it, and later wanted to close down the government of the city of [[Utica, New York|Utica]] while he was its mayor?




On Feb 6, 2023, at 4:10 PM, Kunal Mehta <legoktm@debian.org> wrote:

A better and more robust solution would be to use something like beautifulsoup4 to modify your HTML[1]. I would personally have taken the wikitext, run it through api.php?action=parse or the wt2html Parsoid API, and then used an HTML parser to modify it as needed.