Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create external link references in AsciiDoc without repeating the URL multiple times?

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.

People also ask

How do I create a link in AsciiDoc?

To define a link in Asciidoc markup we only have to type the URL followed by an optional text for the link in square brackets ( [text link] ). With Asciidoctor we can add extra attributes that can be used when the content is generated.

What is the difference between AsciiDoc and Asciidoctor?

The original processor, named AsciiDoc, is written in Python. A more modern implementation, named Asciidoctor, is written in Ruby.

How do you write AsciiDoc?

You can just start typing. In Asciidoctor, adjacent or consecutive lines of text form a paragraph element. To start a new paragraph after another element, such as a section title or table, hit the RETURN key twice to insert a blank line, and then continue typing your content.

Does GitLab support AsciiDoc?

all tiers. GitLab uses the Asciidoctor gem to convert AsciiDoc content to HTML5. Consult the Asciidoctor User Manual for a complete Asciidoctor reference.


2 Answers

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

like image 70
Berthold Gehrke Avatar answered Sep 27 '22 19:09

Berthold Gehrke


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]
    
like image 33
devGeek Avatar answered Sep 27 '22 19:09

devGeek