使用 AsciiDoctor,如何在源代码块和示例块中传递变量?

With AsciiDoctor, how to pass variables in source and example blocks?

有人知道如何在 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
====

但这就是我得到的:

实际上第一个 "example" 有效,但它不是理想的解决方案,因为:

期待您的意见。提前致谢!

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
====