You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can handle nested templates and other tricky syntax that would cause bugs in a simpler system
Cons:
Need to use an API, which makes unit testing more difficult
Need to learn the library, which looks a bit complicated
Parsoid?
The "wikitext to lint" feature looks promising. https://www.mediawiki.org/wiki/Parsoid/API . only returns incorrect HTML/wikicode. doesn't return the abstract syntax tree
"gets the HTML, puts it in an iframe, and then uses that to find templates, etc. in Parsoid, everything important is an HTML element, so it's almost the same thing as using the usual document.* functions"
Custom parser class?
Other option: I could write my own parser class, or look for a generic parser library. but then it would run into things like not recognizing tags and other wikicode-specific syntax, without lots of additional code anyway
Module:Template_parser?
Other option: feed it to https://en.wiktionary.org/wiki/Module:template_parser using the API. note the link is wiktionary, not wikipedia. "theknightwho — Today at 3:36 AM. Just so you know the limitations: the only objects it parses are templates, arguments and headings, and it won’t care if they’re valid or not (since the preprocessor doesn’t either) - however, that kind of thing is evaluated if you use any of the iterators, but obviously that means they’re slower
(By valid, I mean it doesn’t care that something like {{<}} can’t be a real template)"
The text was updated successfully, but these errors were encountered:
NovemLinguae
changed the title
Use Parsoid for template parameter modification?
Use a library or API for wikitext template parameter modification
May 12, 2024
Pros:
Cons:
Parsoid?
The "wikitext to lint" feature looks promising. https://www.mediawiki.org/wiki/Parsoid/API .only returns incorrect HTML/wikicode. doesn't return the abstract syntax treeeditProtectedHelper?
Izno says there's a user script that uses Parsoid to do the same thing at https://en.wikipedia.org/wiki/User:Jackmcbarn/editProtectedHelper.js
parsoid-document?
This looks like a possible Parsoid wrapper for user scripts: https://github.com/ChlodAlejandro/parsoid-document, https://chlodalejandro.github.io/parsoid-document/
Chlod comments on Discord:
https://github.com/ChlodAlejandro/parsoid-document/blob/master/src/ParsoidDocument.module.ts
"gets the HTML, puts it in an iframe, and then uses that to find templates, etc. in Parsoid, everything important is an HTML element, so it's almost the same thing as using the usual document.* functions"
Custom parser class?
Other option: I could write my own parser class, or look for a generic parser library. but then it would run into things like not recognizing tags and other wikicode-specific syntax, without lots of additional code anyway
Module:Template_parser?
Other option: feed it to https://en.wiktionary.org/wiki/Module:template_parser using the API. note the link is wiktionary, not wikipedia. "theknightwho — Today at 3:36 AM. Just so you know the limitations: the only objects it parses are templates, arguments and headings, and it won’t care if they’re valid or not (since the preprocessor doesn’t either) - however, that kind of thing is evaluated if you use any of the iterators, but obviously that means they’re slower
(By valid, I mean it doesn’t care that something like {{<}} can’t be a real template)"
The text was updated successfully, but these errors were encountered: