10

In markdown I can write:

[example1][myid]

[example2][myid]

[myid]: http://example.com

so I don't have to retype the full external link multiple times.

Is there an analogous feature in AsciiDoc? Specially interested in the Asciidoctor implementation.

So far I could only find:

  • internal cross references with <<>>
  • I think I saw a replacement feature of type :myid:, but I can't find it anymore. And I didn't see how to use different texts for each link however.
Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985

2 Answers2

6

Probably you mean something like this:

Userguide Chapter 28.1. Setting configuration entries

... Attribute entries promote clarity and eliminate repetition URLs and file names in AsciiDoc3 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/asciidoc3/
:homepage:  http://asciidoc3.org[AsciiDoc3 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}.

...

BTW, there is a 100% Python3 port available now: https://asciidoc3.org

Berthold Gehrke
  • 336
  • 2
  • 3
6

I think you are looking for this (and both will work just fine),

https://www.google.com[Google]

or

link: https://google.com[Google]

Reference: Ascii Doc User Manual Link


Update #1: Use of link along with variables in asciidoc

Declare variable

:url: https://www.google.com  

Use variable feature using format mentioned above

  1. Using ' Link with label '

    {url}[Google]
    
  2. Using a relative link

    link:{url}[Google]
    
devGeek
  • 213
  • 3
  • 7
  • I want to not have to type `https://google.com` multiple times when linking to it multiple times. – Ciro Santilli OurBigBook.com Jun 11 '18 at 06:24
  • 1
    @CiroSantilli新疆改造中心六四事件法轮功 You can use variable feature of asciidoc for this. Please refer the update in the answer on how to do it. You can also try it [here](https://www.asciidoclive.com/) by copying the code snippets in the answer. – devGeek Jun 11 '18 at 07:45
  • This had already been mentioned on the other answer: https://stackoverflow.com/a/50241560/895245 – Ciro Santilli OurBigBook.com Jun 11 '18 at 07:49
  • 1
    @CiroSantilli新疆改造中心六四事件法轮功 Just a friendly suggestion: If you've had your question answered, you can accept it and let others know this thread has been answered by choosing any one of the answers listed. :) – devGeek Jun 11 '18 at 07:55
  • Thanks dev, I'm keeping my accepts as a helper for legendary :-) – Ciro Santilli OurBigBook.com Jun 11 '18 at 08:55
  • This does not work if url has double `__` ([link](https://docs.asciidoctor.org/asciidoc/latest/macros/complex-urls/)). – 71GA May 17 '23 at 20:19