Skip to content

Commit 4904a4f

Browse files
committed
✨ NEW: Add inv_link extension
1 parent 38559cb commit 4904a4f

File tree

16 files changed

+523
-59
lines changed

16 files changed

+523
-59
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ In particular for users, this update alters the parsing of tables to be consiste
363363

364364
### New Features ✨
365365

366-
- **Task lists** utilise the [markdown-it-py tasklists plugin](markdown_it:md/plugins), and are applied to Markdown list items starting with `[ ]` or `[x]`.
366+
- **Task lists** utilise the [markdown-it-py tasklists plugin](inv:markdown_it#md/plugins), and are applied to Markdown list items starting with `[ ]` or `[x]`.
367367

368368
```markdown
369369
- [ ] An item that needs doing
@@ -541,7 +541,7 @@ substitutions:
541541
{{ key1 }}
542542
```
543543

544-
The substitutions are assessed as [jinja2 expressions](http://jinja.palletsprojects.com/) and includes the [Sphinx Environment](https://www.sphinx-doc.org/en/master/extdev/envapi.html) as `env`, so you can do powerful thinks like:
544+
The substitutions are assessed as [jinja2 expressions](http://jinja.palletsprojects.com/) and includes the [Sphinx Environment](inv:sphinx#extdev/envapi) as `env`, so you can do powerful thinks like:
545545

546546
```
547547
{{ [key1, env.docname] | join('/') }}

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
"substitution",
9898
"tasklist",
9999
"attrs_inline",
100+
"inv_link",
100101
]
101102
myst_number_code_blocks = ["typescript"]
102103
myst_heading_anchors = 2

docs/configuration.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ Full details in the [](syntax/extensions) section.
6969
amsmath
7070
: enable direct parsing of [amsmath](https://ctan.org/pkg/amsmath) LaTeX equations
7171

72+
attrs_inline
73+
: Enable inline attribute parsing, [see here](syntax/attributes) for details
74+
7275
colon_fence
7376
: Enable code fences using `:::` delimiters, [see here](syntax/colon_fence) for details
7477

@@ -87,6 +90,9 @@ html_admonition
8790
html_image
8891
: Convert HTML `<img>` elements to sphinx image nodes, [see here](syntax/images) for details
8992

93+
inv_link
94+
: Enable the `inv:` schema for Markdown link destinations, [see here](syntax/inv_links) for details
95+
9096
linkify
9197
: Automatically identify "bare" web URLs and add hyperlinks
9298

@@ -117,7 +123,7 @@ WARNING: Non-consecutive header level increase; H1 to H3 [myst.header]
117123

118124
**In general, if your build logs any warnings, you should either fix them or [raise an Issue](https://github.com/executablebooks/MyST-Parser/issues/new/choose) if you think the warning is erroneous.**
119125

120-
However, in some circumstances if you wish to suppress the warning you can use the [`suppress_warnings`](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-suppress_warnings) configuration option, e.g.
126+
However, in some circumstances if you wish to suppress the warning you can use the <inv:sphinx#suppress_warnings> configuration option, e.g.
121127

122128
```python
123129
suppress_warnings = ["myst.header"]

docs/docutils.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The commands are based on the [Docutils Front-End Tools](https://docutils.source
3636
:::
3737

3838
:::{versionadded} 0.19.0
39-
`myst-suppress-warnings` replicates the functionality of sphinx's [`suppress_warnings`](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-suppress_warnings) for `myst.` warnings in the `docutils` CLI.
39+
`myst-suppress-warnings` replicates the functionality of sphinx's <inv:sphinx#suppress_warnings> for `myst.` warnings in the `docutils` CLI.
4040
:::
4141

4242
The CLI commands can also utilise the [`docutils.conf` configuration file](https://docutils.sourceforge.io/docs/user/config.html) to configure the behaviour of the CLI commands. For example:

docs/faq/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ If you encounter any issues with this feature, please don't hesitate to report i
102102
(howto/autodoc)=
103103
### Use `sphinx.ext.autodoc` in Markdown files
104104

105-
The [Sphinx extension `autodoc`](sphinx:sphinx.ext.autodoc), which pulls in code documentation from docstrings, is currently hard-coded to parse reStructuredText.
105+
The [Sphinx extension `autodoc`](inv:sphinx#sphinx.ext.autodoc), which pulls in code documentation from docstrings, is currently hard-coded to parse reStructuredText.
106106
It is therefore incompatible with MyST's Markdown parser.
107107
However, the special [`eval-rst` directive](syntax/directives/parsing) can be used to "wrap" `autodoc` directives:
108108

@@ -142,7 +142,7 @@ See the [](syntax/header-anchors) section of extended syntaxes.
142142
:::
143143

144144
If you'd like to *automatically* generate targets for each of your section headers,
145-
check out the {external+sphinx:std:doc}`autosectionlabel <usage/extensions/autosectionlabel>`
145+
check out the [autosectionlabel](inv:sphinx#usage/*/autosectionlabel)
146146
sphinx feature. You can activate it in your Sphinx site by adding the following to your
147147
`conf.py` file:
148148

@@ -179,7 +179,7 @@ Moved to [](myst-warnings)
179179
### Sphinx-specific page front matter
180180

181181
Sphinx intercepts front matter and stores them within the global environment
182-
(as discussed in the {external+sphinx:std:doc}`sphinx documentation <usage/restructuredtext/field-lists>`.
182+
(as discussed in the [sphinx documentation](inv:sphinx#usage/*/field-lists)).
183183
There are certain front-matter keys (or their translations) that are also recognised specifically by docutils and parsed to inline Markdown:
184184

185185
- `author`
@@ -228,7 +228,7 @@ emphasis syntax will now be disabled. For example, the following will be rendere
228228
*emphasis is now disabled*
229229
```
230230

231-
For a list of all the syntax elements you can disable, see the [markdown-it parser guide](markdown_it:using).
231+
For a list of all the syntax elements you can disable, see the [markdown-it parser guide](inv:markdown_it#using).
232232

233233
## Common errors and questions
234234

docs/intro.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ conda install -c conda-forge myst-parser
2828
(intro/sphinx)=
2929
## Enable MyST in Sphinx
3030

31-
To get started with Sphinx, see their {external+sphinx:std:doc}`quick-start guide <usage/quickstart>`.
31+
To get started with Sphinx, see their [quick-start guide](inv:sphinx#usage/quickstart).
3232

3333
To use the MyST parser in Sphinx, simply add the following to your `conf.py` file:
3434

@@ -80,7 +80,7 @@ $ myst-docutils-html5 --stylesheet= myfile.md
8080
```
8181

8282
To include this document within a Sphinx project,
83-
include `myfile.md` in a [`toctree` directive](sphinx:toctree-directive) on an index page.
83+
include `myfile.md` in a [`toctree` directive](inv:sphinx#toctree-directive) on an index page.
8484

8585
## Extend CommonMark with roles and directives
8686

docs/syntax/optional.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ myst:
1313
:width: 200px
1414
```
1515
key4: example
16-
confpy: sphinx `conf.py` {external+sphinx:std:doc}`configuration file <usage/configuration>`
16+
confpy: sphinx `conf.py` [configuration file](inv:sphinx#usage/configuration)
1717
---
1818

1919
(syntax/extensions)=
2020

2121
# Syntax Extensions
2222

23-
MyST-Parser is highly configurable, utilising the inherent "plugability" of the [markdown-it-py](markdown_it:index) parser.
23+
MyST-Parser is highly configurable, utilising the inherent "plugability" of the [markdown-it-py](inv:markdown_it#index) parser.
2424
The following syntaxes are optional (disabled by default) and can be enabled *via* the sphinx `conf.py` (see also [](sphinx/config-options)).
25-
Their goal is generally to add more *Markdown friendly* syntaxes; often enabling and rendering [markdown-it-py plugins](markdown_it:md/plugins) that extend the [CommonMark specification](https://commonmark.org/).
25+
Their goal is generally to add more *Markdown friendly* syntaxes; often enabling and rendering [markdown-it-py plugins](inv:markdown_it#md/plugins) that extend the [CommonMark specification](https://commonmark.org/).
2626

2727
To enable all the syntaxes explained below:
2828

@@ -36,6 +36,7 @@ myst_enable_extensions = [
3636
"fieldlist",
3737
"html_admonition",
3838
"html_image",
39+
"inv_link",
3940
"linkify",
4041
"replacements",
4142
"smartquotes",
@@ -101,7 +102,7 @@ Math is parsed by adding to the `myst_enable_extensions` list option, in the {{
101102
- `"dollarmath"` for parsing of dollar `$` and `$$` encapsulated math.
102103
- `"amsmath"` for direct parsing of [amsmath LaTeX environments](https://ctan.org/pkg/amsmath).
103104

104-
These options enable their respective Markdown parser plugins, as detailed in the [markdown-it plugin guide](markdown_it:md/plugins).
105+
These options enable their respective Markdown parser plugins, as detailed in the [markdown-it plugin guide](inv:markdown_it#md/plugins).
105106

106107
:::{versionchanged} 0.13.0
107108
`myst_dmath_enable=True` and `myst_amsmath_enable=True` are deprecated, and replaced by `myst_enable_extensions = ["dollarmath", "amsmath"]`
@@ -231,7 +232,7 @@ See [the extended syntax option](syntax/amsmath).
231232
(syntax/mathjax)=
232233
### Mathjax and math parsing
233234
234-
When building HTML using the {external+sphinx:mod}`sphinx.ext.mathjax <sphinx.ext.mathjax>` extension (enabled by default),
235+
When building HTML using the <inv:sphinx#sphinx.ext.mathjax> extension (enabled by default),
235236
If `dollarmath` is enabled, Myst-Parser injects the `tex2jax_ignore` (MathJax v2) and `mathjax_ignore` (MathJax v3) classes in to the top-level section of each MyST document, and adds the following default MathJax configuration:
236237
237238
MathJax version 2 (see [the tex2jax preprocessor](https://docs.mathjax.org/en/v2.7-latest/options/preprocessors/tex2jax.html#configure-tex2jax):
@@ -353,7 +354,7 @@ This may lead to unexpected outcomes.
353354

354355
:::
355356

356-
Substitution references are assessed as [Jinja2 expressions](http://jinja.palletsprojects.com) which can use [filters](https://jinja.palletsprojects.com/en/2.11.x/templates/#list-of-builtin-filters), and also contains the {external+sphinx:std:doc}`Sphinx Environment <extdev/envapi>` in the context (as `env`).
357+
Substitution references are assessed as [Jinja2 expressions](http://jinja.palletsprojects.com) which can use [filters](https://jinja.palletsprojects.com/en/2.11.x/templates/#list-of-builtin-filters), and also contains the [Sphinx Environment](inv:sphinx#extdev/envapi) in the context (as `env`).
357358
Therefore you can do things like:
358359

359360
```md
@@ -540,7 +541,7 @@ $ myst-anchors -l 2 docs/syntax/optional.md
540541

541542
By adding `"deflist"` to `myst_enable_extensions` (in the {{ confpy }}),
542543
you will be able to utilise definition lists.
543-
Definition lists utilise the [markdown-it-py deflist plugin](markdown_it:md/plugins), which itself is based on the [Pandoc definition list specification](http://johnmacfarlane.net/pandoc/README.html#definition-lists).
544+
Definition lists utilise the [markdown-it-py deflist plugin](inv:markdown_it#md/plugins), which itself is based on the [Pandoc definition list specification](http://johnmacfarlane.net/pandoc/README.html#definition-lists).
544545

545546
This syntax can be useful, for example, as an alternative to nested bullet-lists:
546547

@@ -619,7 +620,7 @@ Term 3
619620

620621
By adding `"tasklist"` to `myst_enable_extensions` (in the {{ confpy }}),
621622
you will be able to utilise task lists.
622-
Task lists utilise the [markdown-it-py tasklists plugin](markdown_it:md/plugins),
623+
Task lists utilise the [markdown-it-py tasklists plugin](inv:markdown_it#md/plugins),
623624
and are applied to markdown list items starting with `[ ]` or `[x]`:
624625

625626
```markdown
@@ -691,7 +692,7 @@ based on the [reStructureText syntax](https://docutils.sourceforge.io/docs/ref/r
691692
print("Hello, world!")
692693
```
693694

694-
A prominent use case of field lists is for use in API docstrings, as used in [Sphinx's docstring renderers](sphinx:python-domain):
695+
A prominent use case of field lists is for use in API docstrings, as used in [Sphinx's docstring renderers](inv:sphinx#python-domain):
695696

696697
````md
697698
```{py:function} send_message(sender, priority)
@@ -726,16 +727,16 @@ Currently `sphinx.ext.autodoc` does not support MyST, see [](howto/autodoc).
726727
(syntax/attributes)=
727728
## Inline attributes
728729

730+
:::{versionadded} 0.19
731+
This feature is in *beta*, and may change in future versions.
732+
It replace the previous `attrs_image` extension, which is now deprecated.
733+
:::
734+
729735
By adding `"attrs_inline"` to `myst_enable_extensions` (in the {{ confpy }}),
730736
you can enable parsing of inline attributes after certain inline syntaxes.
731737
This is adapted from [djot inline attributes](https://htmlpreview.github.io/?https://github.com/jgm/djot/blob/master/doc/syntax.html#inline-attributes),
732738
and also related to [pandoc bracketed spans](https://pandoc.org/MANUAL.html#extension-bracketed_spans).
733739

734-
:::{important}
735-
This feature is in *beta*, and may change in future versions.
736-
It replace the previous `attrs_image` extension, which is now deprecated.
737-
:::
738-
739740
Attributes are specified in curly braces after the inline syntax.
740741
Inside the curly braces, the following syntax is recognised:
741742

docs/syntax/roles-and-directives.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ by interpreting a chuck of text as a specific type of markup, according to its n
88
Mostly all
99
[docutils roles](https://docutils.sourceforge.io/docs/ref/rst/roles.html),
1010
[docutils directives](https://docutils.sourceforge.io/docs/ref/rst/directives.html),
11-
{external+sphinx:std:doc}`Sphinx roles <usage/restructuredtext/roles>`, or
12-
{external+sphinx:std:doc}`Sphinx directives <usage/restructuredtext/directives>`
11+
[Sphinx roles](inv:sphinx#usage/*/roles), or
12+
[Sphinx directives](inv:sphinx#usage/*/directives)
1313
can be used in MyST.
1414

1515
## Syntax
@@ -421,6 +421,6 @@ For example:
421421

422422
> {sub-ref}`today` | {sub-ref}`wordcount-words` words | {sub-ref}`wordcount-minutes` min read
423423
424-
`today` is replaced by either the date on which the document is parsed, with the format set by [`today_fmt`](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-today_fmt), or the `today` variable if set in the configuration file.
424+
`today` is replaced by either the date on which the document is parsed, with the format set by <inv:sphinx#today_fmt>, or the `today` variable if set in the configuration file.
425425

426426
The reading speed is computed using the `myst_words_per_minute` configuration (see the [Sphinx configuration options](sphinx/config-options)).

0 commit comments

Comments
 (0)