列表中的代码片段并防止在 Creole wiki 中重新开始编号

发布于 2024-11-25 23:39:53 字数 482 浏览 0 评论 0原文

我有以下代码:

# Initial instructions here.
# Some instructions here. See code snippet below.
{{{
#!python

def foo():
  return bar
}}}
# More instructions here. Why does the numbering restart at 1?
# Final instructions.

解析该代码时,我会得到以下内容:

1.此处为初始说明。
2. 这里有一些说明。请参阅下面的代码片段。
def foo():
  返回栏

1. 更多后续说明请参见此处。为什么编号从 1 重新开始?
2. 最后说明。

问题:如何在列表中嵌入代码片段,以便代码片段下方的列表项不会从 1 重新开始?

I have the following code:

# Initial instructions here.
# Some instructions here. See code snippet below.
{{{
#!python

def foo():
  return bar
}}}
# More instructions here. Why does the numbering restart at 1?
# Final instructions.

When that code is parsed, I'd get the following:

1. Initial instructions here.
2. Some instructions here. See code snippet below.

def foo():
  return bar

1. More continuing instructions here. Why does the numbering restart at 1?
2. Final instructions.

Question: How do I embed code snippets within a list so that the list items below the code snippet won't restart at 1?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柳絮泡泡 2024-12-02 23:39:53

内联预格式化文本适用于列表。您可以使用它通过分隔每一行来近似块预格式化。这不是一个很好的解决方案,但它可能适用于某些情况。

# Initial instructions here.
# Some instructions here. See code snippet below.
** {{{#!python}}}
** {{{}}}
** {{{def foo():}}}
** {{{  return bar}}}
# More instructions here. Why does the numbering restart at 1?
# Final instructions.

产量:

<ol>
	<li>Initial instructions here.</li>
	<li>Some instructions here. See code snippet below.
	<ul>
		<li><tt>#!python</tt></li>
		<li><tt></tt></li>
		<li><tt>def foo():</tt></li>
		<li><tt>  return bar</tt></li>
	</ul></li>
	<li>More instructions here. Why does the numbering restart at 1?</li>
	<li>Final instructions.</li>
</ol>

Inline preformatted text works in lists. You can use this to approximate block preformatting by separating each line. This isn't a great solution, but it might work for some cases.

# Initial instructions here.
# Some instructions here. See code snippet below.
** {{{#!python}}}
** {{{}}}
** {{{def foo():}}}
** {{{  return bar}}}
# More instructions here. Why does the numbering restart at 1?
# Final instructions.

Yeilds:

<ol>
	<li>Initial instructions here.</li>
	<li>Some instructions here. See code snippet below.
	<ul>
		<li><tt>#!python</tt></li>
		<li><tt></tt></li>
		<li><tt>def foo():</tt></li>
		<li><tt>  return bar</tt></li>
	</ul></li>
	<li>More instructions here. Why does the numbering restart at 1?</li>
	<li>Final instructions.</li>
</ol>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文