任何人都知道如何在Asciidoc中将变量{var}
传递到[source]
块和示例块(带有====
)中吗?
我尝试了以下
:country: France
:city: Shanghai
[source]
----
print("{country} is a country")
print("{city} is a city")
----
.Example
====
{country} is a country +
{city} is a city
====
.Example with better alignment
====
{country} is a country
{city} is a city
====
但这就是我得到的:
实际上,第一个“示例”正在运行,但这不是理想的解决方案,因为:
+
期待您的投入。预先感谢!
答案 0 :(得分:2)
如here所述,您需要在代码块中打开属性替换。您可以使用[subs="attributes"]
完整的示例来实现它,该示例应类似于:
[source, subs="attributes"]
----
print("{country} is a country")
print("{city} is a city")
----
.Example with better alignment
====
[subs="attributes"]
{country} is a country
{city} is a city
====