@@ -78,7 +78,7 @@ For example, using `myst_heading_anchors = 2`:
7878
7979## A heading with slug
8080
81- [ ... ] ( #a-heading-with-slug )
81+ < project: #a-heading-with-slug>
8282
8383[ Explicit title] ( #a-heading-with-slug-1 )
8484::::
@@ -136,74 +136,84 @@ or an **internal** target, such as a file, heading or figure within the same pro
136136
137137By default, MyST will resolve link destinations according to the following rules:
138138
139- 1 . Destinations beginning with ` inv: ` will be treated as links to intersphinx references ( [ see below ] ( #syntax/inv_links ) ).
139+ 1 . Destination beginning with a scheme (e.g. ` xxx: ` ), will be handled according to that scheme:
140140
141- 2 . Autolinks or destinations beginning with ` http: ` , ` https: ` , ` ftp: ` , or ` mailto: ` will be treated as external [ URL] links.
141+ {style=lower-roman}
142+ 1 . Destinations beginning with ` project: ` will be treated as internal references
143+ 2 . Destinations beginning with ` path: ` will be treated as downloadable files
144+ 3 . Destinations beginning with ` inv: ` will be treated as intersphinx references
145+ 4 . Autolinks or destinations beginning with ` http: ` , ` https: ` , ` ftp: ` , or ` mailto: ` will be treated as external [ URL] links.
142146
143- 3 . Destinations which point to a local file path are treated as links to that file.
147+ 2 . Destinations which point to a local file path are treated as links to that file.
144148
145- - If the destination is a relative path, it is resolved relative to the current file.
146- - If the destination is an absolute path (starts with ` / ` ), it is resolved relative to the root of the project (i.e. the source directory).
147- - If that path relates to another document in the project (e.g. a ` .md ` or ` .rst ` file), then it will link to the first heading in that document.
148- - Links to project documents can also include a ` # ` fragment identifier, to link to a specific heading in that document.
149- - If the path is to a non-source file (e.g. a ` .png ` or ` .pdf ` file), then the link will be to the file itself, e.g. to download it.
149+ {style=lower-roman}
150+ 1 . If the destination is a relative path, it is resolved relative to the current file.
151+ 2 . If the destination is an absolute path (starts with ` / ` ), it is resolved relative to the root of the project (i.e. the source directory).
152+ 3 . If that path relates to another document in the project (e.g. a ` .md ` or ` .rst ` file), then it will link to the first heading in that document.
153+ 4 . Links to project documents can also include a ` # ` fragment identifier, to link to a specific heading in that document.
154+ 5 . If the path is to a non-source file (e.g. a ` .png ` or ` .pdf ` file), then the link will be to the file itself, e.g. to download it.
150155
151- 4 . Destinations beginning with ` # ` will be treated as internal references.
156+ 3 . Destinations beginning with ` # ` will be treated as internal references.
152157
153- - First, explicit target in the same file are searched for, if not found
154- - Then, implicit targets in the same file are searched for, if not found
155- - Then, explicit targets across the whole project are searched for, if not found
156- - Then, intersphinx references are searched for, if not found
157- - A warning is emitted and the destination is left as an external link.
158+ {style=lower-roman}
159+ 1 . First, explicit targets in the same file are searched for, if not found
160+ 2 . Then, implicit targets in the same file are searched for, if not found
161+ 3 . Then, explicit targets across the whole project are searched for, if not found
162+ 4 . Then, intersphinx references are searched for, if not found
163+ 5 . A warning is emitted and the destination is left as an external link.
158164
159165:::{note}
160166Local file path resolution and cross-project references are not available in [ single page builds] ( #myst-docutils )
161167:::
162168
163169### Explicit vs implicit link text
164170
165- If the link text is explicitly given, e.g. ` [text](dest) ` , then the link text will be the given text .
171+ If the link text is explicitly given, e.g. ` [text](# dest) ` , then the rendered text will be that .
166172This text can contain nested inline markup, such as ` [*emphasis*](#syntax/emphasis) ` {l=md}.
167173
168- If no text or ` ... ` is given , e.g. ` [](dest) ` or ` [...]( dest) ` , then MyST will attempt to resolve an implicit text.
174+ If no text is given or it is an auto-link , e.g. ` [](# dest) ` or ` <project:# dest> ` , then MyST will attempt to resolve an implicit text.
169175For example, if the destination is a heading, then the heading text will be used as the link text,
170176or if the destination is a figure/table then the caption will be used as the link text.
171177Otherwise, the link text will be the destination itself.
172178
173- ### Some examples
179+ ### Examples
174180
175- Here are some examples:
181+ #### Autolinks
176182
177- :::{list-table}
178- :header-rows: 1
183+ :::{myst-example}
179184
180- * - Type
181- - Syntax
182- - Rendered
185+ : External URL: < https://example.com >
186+ : Internal target reference: < project:#cross-references >
187+ : Internal file reference: < project:../intro.md >
188+ : Internal file -> heading reference: < project:../intro.md#-get-started >
189+ : Downloadable file: < path:example.txt >
190+ : Intersphinx reference: < inv:sphinx:std#index >
183191
184- * - Autolink
185- - ` <https://example.com> `
186- - < https://example.com >
192+ :::
193+
194+ #### Inline links with implicit text
195+
196+ :::{myst-example}
187197
188- * - External URL
189- - ` [example.com](https://example.com) `
190- - [ example.com] ( https://example.com )
198+ : External URL: [ ] ( https://example.com )
199+ : Internal target reference: [ ] ( #cross-references )
200+ : Internal file reference: [ ] ( ../intro.md )
201+ : Internal file -> heading reference: [ ] ( ../intro.md#-get-started )
202+ : Downloadable file: [ ] ( example.txt )
203+ : Intersphinx reference: [ ] ( inv:sphinx:std#index )
191204
192- * - Document file
193- - ` [Source file](../intro.md) `
194- - [ Source file] ( ../intro.md )
205+ :::
195206
196- * - Non-document file
197- - ` [Non-source file](example.txt) `
198- - [ Non-source file] ( example.txt )
207+ #### Inline links with explicit text
199208
200- * - Local heading
201- - ` [...](#cross-references) `
202- - [ ...] ( #cross-references )
209+ :::{myst-example}
203210
204- * - Heading in other file
205- - ` [Heading](../intro.md#installation) `
206- - [ Heading] ( ../intro.md#installation )
211+ : External URL: [ Explicit text] ( https://example.com )
212+ : Internal target reference: [ Explicit text] ( #cross-references )
213+ : Internal file reference: [ Explicit text] ( ../intro.md )
214+ : Internal file -> heading reference: [ Explicit text] ( ../intro.md#-get-started )
215+ : Downloadable file: [ Explicit text] ( example.txt )
216+ : Intersphinx reference: [ Explicit text] ( inv:sphinx:std#index )
207217
208218:::
209219
@@ -341,23 +351,23 @@ Here are some examples:
341351 - Rendered
342352
343353* - Autolink, full
344- - ` <inv:sphinx:std:doc#index>`
354+ - ` <inv:sphinx:std:doc#index>` {l=myst}
345355 - <inv:sphinx:std:doc#index>
346356
347357* - Link, full
348- - ` [Sphinx](inv:sphinx:std:doc#index)`
358+ - ` [Sphinx](inv:sphinx:std:doc#index)` {l=myst}
349359 - [Sphinx](inv:sphinx:std:doc#index)
350360
351361* - Autolink, no type
352- - ` <inv:sphinx:std#index>`
362+ - ` <inv:sphinx:std#index>` {l=myst}
353363 - <inv:sphinx:std#index>
354364
355365* - Autolink, no domain
356- - ` <inv:sphinx:*:doc#index>`
366+ - ` <inv:sphinx:*:doc#index>` {l=myst}
357367 - <inv:sphinx:*:doc#index>
358368
359369* - Autolink, only name
360- - ` <inv:#*.Sphinx>`
370+ - ` <inv:#*.Sphinx>` {l=myst}
361371 - <inv:#*.Sphinx>
362372
363373:: :
@@ -371,21 +381,21 @@ These can also within MyST documents, although it is recommended to use the Mark
371381:::{myst-example}
372382- {ref}`syntax/referencing`, {ref}`Explicit text <syntax/referencing>`
373383- {term}`my other term`
374- - {doc}`../intro`
375- - {download}`example.txt`
376- - {py:class}`mypackage.MyClass`
377- - {external:class}`sphinx.application.Sphinx`
378- - {external+sphinx:ref}`code-examples`
384+ - {doc}`../intro`, {doc}`Explicit text <../intro>`
385+ - {download}`example.txt`, {download}`Explicit text <example.txt>`
386+ - {py:class}`mypackage.MyClass`, {py:class}`Explicit text <mypackage.MyClass>`
387+ - {external:class}`sphinx.application.Sphinx`, {external:class}`Explicit text <sphinx.application.Sphinx>`
388+ - {external+sphinx:ref}`code-examples`, {external+sphinx:ref}`Explicit text <code-examples>`
379389
380390---
381391
382- - [... ][syntax], [Explicit text][syntax]
383- - [... ](<#my other term>)
384- - [... ](../intro.md)
385- - [... ](example.txt)
386- - [... ](#mypackage.MyClass)
387- - [...](#sphinx.application. Sphinx) , [...](inv:#* Sphinx)
388- - [... ](inv:sphinx#code-examples)
392+ - <project:#syntax/referencing>, [ ][syntax], [Explicit text][syntax]
393+ - [](<#my other term>)
394+ - <project:../intro.md>, [Explicit text ](../intro.md)
395+ - <path:example.txt>, [Explicit text ](example.txt)
396+ - <project:#mypackage.MyClass>, [Explicit text ](#mypackage.MyClass)
397+ - <inv:#* Sphinx> , [Explicit text](#sphinx.application. Sphinx)
398+ - <inv:sphinx#code-examples>, [Explicit text ](inv:sphinx#code-examples)
389399
390400[syntax] : # syntax/referencing
391401:: :
0 commit comments