-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trimming of template values #19
base: master
Are you sure you want to change the base?
Conversation
The same behavior could be also implemented for the keys. They are also stored as However, this would be something independent from this here and may requires further discussion. |
I'd like to keep the parsed wikitext intact. That is, if you call {{Infobox book
| name = So Long, and Thanks for All the Fish
| title_orig =
| translator =
| image = SoLongAndThanksForAllTheFish.jpg
| caption = First Edition (UK) with [[Lenticular printing|lenticular print]] of a [[plesiosaurus]] and [[walrus]]
| author = [[Douglas Adams]]
| illustrator =
...
}} turns into this when I submit my change {{Infobox book|name=So Long, and Thanks for All the Fish|title_orig=|translator=|image=SoLongAndThanksForAllTheFish.jpg| caption=First Edition (UK) with [[Lenticular printing|lenticular print]] of a [[plesiosaurus]] and [[walrus]]|author=[[Douglas Adams]]|illustrator=
...}} And when writing this library, I think it's acceptable even to trade performance for keeping the input wikitext intact, as when you are working with online bots, most of the time taken is actually on the network. In case you really want to frequently access the template parameters (like when you are working with some offline wikitext dump), you can do the caching (with Dictionary) by yourself. I won't do that for you since I believe you know better what you need than I do. (But we may consider adding some API were there really some general & frequent usage pattern like this.) That being said, I have introduced some helper functions for AST consumer's convenience. I think this one should satisfy your need: MwParserFromScratch/MwParserFromScratch/MwParserUtility.cs Lines 16 to 34 in 7dc014d
This function is also used by You may find the implementation of
You forgot there could be templates, comments, or arguments 😋 {{Foo | param_{{Bar}} <!-- predefined parameter index --> = {{{param_value}}} }} |
Okay, yes that makes a lot of sense to me. I should read some more about the specs before trying to make contributions :P Maybe it makes sense to leave it in the Utils tho. |
Depending on how template parameters have been typed, there may are trailing white-spaces and/or line-breaks.
The wiki editor automatically gets rid of them.