Hi,
On 2/6/23 15:27, Roy Smith wrote:
I want to turn wikitext into HTML for display on a web
front-end I'm
building. For what I'm doing, all I need is a few constructs like
wiklinks, bold, and italic, which I'm able to do with a smallish amount
of mwparserfromhell code.
The one annoyance I've got now is I'm using bootstrap
<https://getbootstrap.com/> in a web front-end, so I don't want <b> and
<i> HTML tags. I want is <span class="fw-bold">
<https://getbootstrap.com/docs/5.0/utilities/text/#font-weight-and-italics> (and
likewise class="fst-italic") Is there some way to tell
mwparserfromhell.nodes.Tag to use that alternate markup when it processes bold or italic
wikicode?
I don't know the answer to your question of modifying mwparserfromhell
to output different tags, but...
Since you say your wikitext is pretty simple, just links, bold and
italic, you could probably get away with just regexing those tags into
your preferred span tags.
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.
[1]
https://beautiful-soup-4.readthedocs.io/en/latest/#modifying-the-tree
-- Kunal / Legoktm