尝试修复MediaWiki模板中的#ifeq语句

我正在尝试在Fandom中创建一个剧透通知模板,并在其下方提供一个可扩展的文本部分。我碰壁了,试图使变量和#ifeq语句正常工作。

这应该起作用的方式,第一个参数是故事类型,并控制#ifeq语句。如果用户将“短篇小说”放入参数1中,则会将标题(参数2)用双引号(“”)引起来。其他任何输入(默认为“新颖”)均用斜体表示。第三个参数是文本部分,您将其标记为破坏者,默认使用内置的MediaWiki类(this)隐藏。

{| style="width:100%; margin-top:1em; border:1px solid #999; font-size:90%; text-align:center;"
|-
! style="padding:0.2em 0.5em; background-color:red;" nowrap="nowrap" class="color1" | ''SPOILER WARNING<nowiki>!!!</nowiki>''
|-
| This section contains spoilers for the {{{1|novel}}} {{#ifeq: {{{1|}}}|short story|{test = """
    test   al,al
    jne    0x514 <asm4+23>
    mov    DWORD PTR [ebp-0x8],0x1
    jmp    0x587 <asm4+138>
    mov    edx,DWORD PTR [ebp-0x8]
    """.splitlines()

i = 0
while i < len(test):
    if test[i].startswith("jne"):
        test[i] = "jne    0x514 <asm4+23>"
    elif test[i].startswith("jmp"):
        test[i] = "jmp    0x587 <asm4+138>"
    i += 1

print("\n".join(test))
} "[[{{{2|{{PAGENAME}}}}}]]"|{lower_red = np.array([0,150,50])}{{{''[[{{{2|{{PAGENAME}}}}}]]''}}. Expand at your own risk.
|-
|}<div class="mw-collapsible mw-collapsed">
{from here}
</div>

来源:https://aeon14.fandom.com/wiki/Template:Spoiler

d228489 回答:尝试修复MediaWiki模板中的#ifeq语句

好的,我发现了问题。原来我在那里有一些多余的括号,而且我在两个字段中都错误地留下了参数1的第二个副本。这是固定代码:

{| style="width:100%; margin-top:1em; border:1px solid #999; font-size:90%; text-align:center;"
|-
! style="padding:0.2em 0.5em; background-color:red;" nowrap="nowrap" class="color1" | ''SPOILER WARNING<nowiki>!!!</nowiki>''
|-
| This section contains spoilers for the {{{1|novel}}} {{#ifeq: {{{1|}}}|short story|"[[{{{2|{{PAGENAME}}}}}]]"|''[[{{{2|{{PAGENAME}}}}}]]''}}. Expand at your own risk.
|-
|}<div class="mw-collapsible mw-collapsed">
{https://testing-library.com/}
</div>
本文链接:https://www.f2er.com/3130340.html

大家都在问