Asciidoc中的文字内的替换 [英] Substitutions inside literals in Asciidoc

查看:127
本文介绍了Asciidoc中的文字内的替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎没有一种方法可以在Asciidoc的文字文本中解析变量(属性,替换项),否则我会丢失某些内容。我希望能够设置一个变量,然后在代码块或文字字符串中这样调用它:

There doesn't appear to be a way to have variables (attributes, substitutions) parsed within literal text in Asciidoc, or else I'm missing something. I want to be able to set a variable and then call it inside a code block or literal string as such:

:version: 1.0.1
[code]
----
tar -xzvf mysoftware-{version}.tar.gz
----

并将其解析为:

tar -xzvf mysoftware-1.0.1.tar.gz

这不可能,对吧?

推荐答案

您可以使用 subs 在任何块中启用它块的属性。 subs 属性接受以下任何一项(在列表中):

You can enable it for any block by using the subs attribute to the block. The subs attribute accepts any of the following (in a list):


  • -禁用替换

  • 普通-执行除标注以外的所有替换

  • verbatim -替换特殊字符并处理标注

  • 特殊字符/特殊字符-替换<,>和&及其相应的实体

  • 引号-应用文本格式

  • 属性-替换属性引用

  • 替换-替换文本和字符引用替换

  • -处理宏

  • post_replacements -替换换行符(+)

  • none - Disables substitutions
  • normal - Performs all substitutions except for callouts
  • verbatim - Replaces special characters and processes callouts
  • specialchars / specialcharacters - Replaces <, >, and & with their corresponding entities
  • quotes - Applies text formatting
  • attributes - Replaces attribute references
  • replacements - Substitutes textual and character reference replacements
  • macros - Processes macros
  • post_replacements - Replaces the line break character (+)

可以找到更多信息用户手册中的示例,其中包含一个非常接近您要完成的任务的示例。

More info can be found in the User Manual, including an example very close to what you're trying to accomplish.

这篇关于Asciidoc中的文字内的替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆