-
Notifications
You must be signed in to change notification settings - Fork 23
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
Expand template contains itself #193
Comments
Oh, that is such a headache... I have no recollection about how we do subst: and safesubst:, but it can't be pretty. The proper way to do it, based on the documentation, would be to actually expand them before anything else... I guess we just do everything in all go. |
Current code ignores them: wikitextprocessor/src/wikitextprocessor/core.py Lines 1403 to 1408 in 958098c
Expand before anything else? I think mediawiki does the opposite. And the "длина слова" template expands to a category link, so this bug doesn't affect the ru extractor much. |
https://en.wikipedia.org/wiki/Help:Substitution#Technical_implementation
Substitutions change the page source itself. Normally templates transclude and are called each time. EDIT: You are correct, I meant that subst: is evaluated before other things, but of course you'd need to expand the template a subst is in in order to get to it... |
I am staring at that template, and my head is starting to hurt. |
Ok, there might be a brighter future here:
We might be able to get away with small changes... The problem with the template in the first post might not be safesubst, it might be "ifsubst" which checks if we're in "substitution mode" (never applicable for us) or "transclusion mode", and if that breaks that might explain the infinite loop? |
I agree we could continue ignore "safesubst", I guess the problem is the template arguments passed to "#ifeq" are expanded before checking the Here is a simplified test: def test_test(self):
self.ctx.add_page("Template:ifsubst", 10, """{{#ifeq:yes|yes
|{{{2|}}}
|{{{1|}}}
}}""")
self.ctx.add_page("Template:длина слова", 10, "{{ifsubst|{{длина слова}}|aaa}}")
self.ctx.start_page("")
self.assertEqual(self.ctx.expand("{{ifsubst|yes|no}}"), "no")
self.assertEqual(self.ctx.expand("{{длина слова}}"), "aaa") |
If we get the behavior of I am still checking all the pages for Templates have them, but those templates are supposed to be used once with EDIT: There's not Template:ifsubst on en.wiktionary.org, but there is on en.wikipedia.org and ru.wiktionary.org |
I'm an idiot, ifsubst uses safesubst:... |
Page: https://ru.wiktionary.org/wiki/footer
Template: https://ru.wiktionary.org/wiki/Шаблон:длина_слова
The "длина_слова" template calls itself if it is used for substitution, or use "main other" template. I think it's "{{{|safesubst:}}}" in the template delays the expansion of the arguments, but our code doesn't do that and expand the "длина_слова" template recursively.
wikitext docs:
The text was updated successfully, but these errors were encountered: