Skip to article content

MyST Markdown allows you to connect your documents to external linked content like Wikipedia, which allow for hover-references with external content. External references are references to structured content or documents that are outside of your project. MyST supports referencing rich content in a growing number of formats, including:

  1. other mystmd projects, with rich cross-linking of content
  2. integrating directly with Wikipedia articles to show tooltips,
  3. linking to other Sphinx documentation using intersphinx,
  4. link to files on GitHub and show inline previews,
  5. showing structured content from scholarly sources like DOIs or RRIDs.

Referencing external MyST projects

When using the HTML renderer for MyST, an API is provided for the deployed site. This provides pre-parsed, structured content as an AST that can be included in other projects and rendered in a tooltip.

In your project configuration, include the references object with named links out to the external MyST projects that you will reference in your project. The example below shows how you would load cross-references that are pulled from the MyST Specification documentation.

references:
  spec: https://mystmd.org/spec

When you specify these in your project configuration, MyST will load the cross-references and provide access to all of the pages and reference targets in that project. References are cached to disk locally in the _build folder, eliminating duplicate web requests on subsequent builds. To delete the cache and manually re-load the references, run myst clean --cache.

To reference content in the linked MyST project, use the xref: protocol in a link followed by the project key (from references), the url path and the target. For example, <xref:spec/tables#example> renders to:
xref:spec/tables#example
and is made of a protocol, project, path and target.

protocol
The protocol for this type of link is xref:, and is what selects for cross-project referencing.
project
the project key above is “spec” which is defined in your local project configuration above.
path
the path is everything that follows the project before the #. It corresponds directly to the URL path in the MyST site. In the example above, path is /tables.
Path is optional in most cases; the target can be resolved against the entire project without the path. An exception to this is headings without an explicit label in the source markdown — these will require path. Note that these references may not be intended to be persistent by the source author, so use caution in linking to them!
target
The target is everything that follows the # and is a named reference in the project. In the example above it is “syntax”.
Target is also optional - if not provided, the cross reference will simply link to a page in the external MyST project. However, without the target, there will not be a rendered tooltip.
When creating a cross reference, you can determine path and target by simply navigating to your target content in the external MyST project and copying the path and fragment from the URL.

If no link text is provided, e.g. [](xref:...), text will be generated from the external project at build-time. You may override this behavior by providing you own text, [text](xref:...).

Referencing external Sphinx documentation

MyST can integrate directly with other Sphinx documentation, which is used in many Python projects including the standard library.

Same as MyST cross references, use the references object to list Sphinx projects. For example, in the demonstration below we will load the Python 3.7 documentation and JupyterBook docs, both of which use sphinx and expose cross references through an objects.inv file.

references:
  python: https://docs.python.org/3.7/
  jupyterbook: https://jupyterbook.org/en/stable/

The behavior of these entries is identical to MyST cross references: the remote objects.inv file, which contains all available project references, is downloaded and cached in the _build folder.

To reference a function, class or label in the linked documentation, use the xref: protocol in a link followed by the project key and the target. For example, <xref:python#library/abc> renders to:
xref:python#library/abc
and is made of a protocol, project and target.

protocol
The protocol for this type of link is xref:, and is what selects for cross-project referencing.
project
the project key above is “python” which is defined in your local project configuration above.
target
The target is everything that follows the # and is a named reference in the project.
In the example above it is “library/abc”.

As with any link, the text can be overridden using markdown link syntax [text](xref:...).

MyST Markdown can directly integrate with Wikipedia to create hover-card information directly integrated into your myst documents. The syntax follows standard markdown links, under the wiki: protocol followed by the page title[1]. As with any other link, you can either follow a [text](wiki:Page_Title) or <wiki:Page_Title>, which if no text is provided for the links will be replaced with the page title.

The links will take you to Wikipedia, as well as provide a tooltip and description directly on the page.

To show different text you can use a similar technique to references:
[my **bold** text](wiki:reference)

GitHub

Issues and Pull Requests

MyST Markdown can directly link and show preview of GitHub issues and Pull Requests, for example, #336 and #87. To enable this, just use a normal link to your

[#87](https://github.com/executablebooks/myst-theme/pull/87)

If you do not include children for the link, then the default text will become owner/repo#123.

Linking to Code

MyST Markdown can directly integrate with links to GitHub to create hover-card information directly integrated into your MyST documents. For example, a link to the linkTransforms plugin code shows a preview of the code. The code preview works for both multiple line numbers and highlighting single lines, which shows the surrounding ten lines, with the referenced line highlighted. If you reference the full file then the first ten lines of the file are shown in the preview.

Linking DOIs

It is possible to include DOIs as external content, and they are also added as citations to your project and show up in the references section at the bottom of a document. See Citations and Bibliography for more details, specifically Simple Referencing with a DOI Link, which explains linking DOIs with the <doi:10.5281/zenodo.6476040> or [](doi:10.5281/zenodo.6476040) to create a citation, for example (doi:10.5281/zenodo.6476040).

Research Resource Identifiers

RRIDs are persistent, unique identifiers for referencing a research resource, such as an antibody, plasmid, organism, or scientific tool. These are helpful for ensuring reproducibility and exact communication in scientific studies. See the RRID website for more information.

MyST Markdown allows you to directly integrate with the RRID database to pull information and validate the links are correct as you are writing documents. The metadata is passed to subsequent systems (e.g. PDF documents, compatible journals and preprint servers) and helps keep your science reproducible.

To create an RRID link, use the rrid: protocol followed by the resource identifier, for example:

References
  1. Cockett, R. (2022). Future of Research Communication & Collaboration. 10.5281/ZENODO.6476040
  2. Ridler, T., Witton, J., Phillips, K. G., Randall, A. D., & Brown, J. T. (2020). Impaired speed encoding and grid cell periodicity in a mouse model of tauopathy. eLife, 9. 10.7554/elife.59045
  3. Rossant, C., Kadir, S. N., Goodman, D. F. M., Schulman, J., Hunter, M. L. D., Saleem, A. B., Grosmark, A., Belluscio, M., Denfield, G. H., Ecker, A. S., Tolias, A. S., Solomon, S., Buzsáki, G., Carandini, M., & Harris, K. D. (2016). Spike sorting for large, dense electrode arrays. Nature Neuroscience, 19(4), 634–641. 10.1038/nn.4268
MyST MarkdownMyST Markdown
Community-driven tools for the future of technical communication and publication