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.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章