Asciidoc 的嵌入式链接写法

多年以前,有一段时间我对 Asciidoc 很感兴趣,尝试用它起草写了一篇博客文章(为什么我说Rust是靠谱的编程语言),偏偏那是一篇很长的文章(大概有一万字),偏偏里面有大量的超级链接,大量的链接夹杂在文字中间,写的我都快吐了。当时也曾专门去找,想知道Asciidoc有没有类似Markdown的嵌入式链接写法([title][name] [name]: url),然而很遗憾,没找到(我觉得官方文档也要背一下锅)。结果就是,那是我第一篇也是唯一一篇用Asciidoc格式正式书写的文章。

今天偶然看到Asciidoc,又去它官方网站找了一遍,还真给找到了嵌入式链接写法,解开了我心中积压多年的一个疑团。下面引用官方文档。(杯具的是,我这里写的还是Markdown,因为CSDN博客编辑器已经官方支持Markdown。)


28.1. Setting configuration entries

Attribute entries promote clarity and eliminate repetition

URLs and file names in AsciiDoc macros are often quite long — they break paragraph flow and readability suffers. The problem is compounded by redundancy if the same name is used repeatedly. Attribute entries can be used to make your documents easier to read and write, here are some examples:

:1:         http://freshmeat.net/projects/asciidoc/
:homepage:  http://asciidoc.org[AsciiDoc home page]
:new:       image:./images/smallnew.png[]
:footnote1: footnote:[A meaningless latin term]

Using previously defined attributes: See the {1}[Freshmeat summary]
or the {homepage} for something new {new}. Lorem ispum {footnote1}.

Note:

  • The attribute entry definition must precede it’s usage.
  • You are not limited to URLs or file names, entire macro calls or arbitrary lines of text can be abbreviated.
  • Shared attributes entries could be grouped into a separate file and included in multiple documents.
发布了275 篇原创文章 · 获赞 442 · 访问量 244万+

猜你喜欢

转载自blog.csdn.net/liigo/article/details/99856200