@@ -78,7 +78,7 @@ For example, using `myst_heading_anchors = 2`:
78
78
79
79
## A heading with slug
80
80
81
- [ ... ] ( #a-heading-with-slug )
81
+ < project: #a-heading-with-slug>
82
82
83
83
[ Explicit title] ( #a-heading-with-slug-1 )
84
84
::::
@@ -136,74 +136,84 @@ or an **internal** target, such as a file, heading or figure within the same pro
136
136
137
137
By default, MyST will resolve link destinations according to the following rules:
138
138
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:
140
140
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.
142
146
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.
144
148
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.
150
155
151
- 4 . Destinations beginning with ` # ` will be treated as internal references.
156
+ 3 . Destinations beginning with ` # ` will be treated as internal references.
152
157
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.
158
164
159
165
:::{note}
160
166
Local file path resolution and cross-project references are not available in [ single page builds] ( #myst-docutils )
161
167
:::
162
168
163
169
### Explicit vs implicit link text
164
170
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 .
166
172
This text can contain nested inline markup, such as ` [*emphasis*](#syntax/emphasis) ` {l=md}.
167
173
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.
169
175
For example, if the destination is a heading, then the heading text will be used as the link text,
170
176
or if the destination is a figure/table then the caption will be used as the link text.
171
177
Otherwise, the link text will be the destination itself.
172
178
173
- ### Some examples
179
+ ### Examples
174
180
175
- Here are some examples:
181
+ #### Autolinks
176
182
177
- :::{list-table}
178
- :header-rows: 1
183
+ :::{myst-example}
179
184
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 >
183
191
184
- * - Autolink
185
- - ` <https://example.com> `
186
- - < https://example.com >
192
+ :::
193
+
194
+ #### Inline links with implicit text
195
+
196
+ :::{myst-example}
187
197
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 )
191
204
192
- * - Document file
193
- - ` [Source file](../intro.md) `
194
- - [ Source file] ( ../intro.md )
205
+ :::
195
206
196
- * - Non-document file
197
- - ` [Non-source file](example.txt) `
198
- - [ Non-source file] ( example.txt )
207
+ #### Inline links with explicit text
199
208
200
- * - Local heading
201
- - ` [...](#cross-references) `
202
- - [ ...] ( #cross-references )
209
+ :::{myst-example}
203
210
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 )
207
217
208
218
:::
209
219
@@ -341,23 +351,23 @@ Here are some examples:
341
351
- Rendered
342
352
343
353
* - Autolink, full
344
- - ` <inv:sphinx:std:doc#index>`
354
+ - ` <inv:sphinx:std:doc#index>` {l=myst}
345
355
- <inv:sphinx:std:doc#index>
346
356
347
357
* - Link, full
348
- - ` [Sphinx](inv:sphinx:std:doc#index)`
358
+ - ` [Sphinx](inv:sphinx:std:doc#index)` {l=myst}
349
359
- [Sphinx](inv:sphinx:std:doc#index)
350
360
351
361
* - Autolink, no type
352
- - ` <inv:sphinx:std#index>`
362
+ - ` <inv:sphinx:std#index>` {l=myst}
353
363
- <inv:sphinx:std#index>
354
364
355
365
* - Autolink, no domain
356
- - ` <inv:sphinx:*:doc#index>`
366
+ - ` <inv:sphinx:*:doc#index>` {l=myst}
357
367
- <inv:sphinx:*:doc#index>
358
368
359
369
* - Autolink, only name
360
- - ` <inv:#*.Sphinx>`
370
+ - ` <inv:#*.Sphinx>` {l=myst}
361
371
- <inv:#*.Sphinx>
362
372
363
373
:: :
@@ -371,21 +381,21 @@ These can also within MyST documents, although it is recommended to use the Mark
371
381
:::{myst-example}
372
382
- {ref}`syntax/referencing`, {ref}`Explicit text <syntax/referencing>`
373
383
- {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>`
379
389
380
390
---
381
391
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)
389
399
390
400
[syntax] : # syntax/referencing
391
401
:: :
0 commit comments