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:
mystmdprojects, with rich cross-linking of content
- integrating directly with Wikipedia articles to show tooltips,
- linking to other Sphinx documentation using intersphinx,
- link to files on GitHub and show inline previews,
- 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 and rendered in a tooltip.
Referencing external Sphinx documentation¶
MyST can integrate directly with other Sphinx documentation, which is used in many Python projects including the standard library.
In your project configuration, include the
references object with named links out to the Sphinx or MyST documentation that you will reference in the project. 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
references: python: https://docs.python.org/3.7/ jupyterbook: https://jupyterbook.org/en/stable/
When you specify these in your project configuration, MyST will load and cache the remote
and provide access to all of the references in that project.
To reference a function, class or label in the linked documentation, use the
myst: protocol in a link followed by the
project key and the target.
<myst:python#library/abc> renders to:
and is made of a
- The protocol for this type of link is
myst:, and is what selects for cross-project referencing.
projectkey above is "python" which is defined in your local project configuration above.
- The project is optional, however, we recommend that you include it to both efficiently look up the reference as well as be explicit as to what project you are referring to.
- If the project is not included, all projects will be searched for the reference in the order given in the
- 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
How to find the intersphinx target?
The HTML IDs that are part of the documentation are not always the targets that are used in the documentation. The easiest way to find the target to use is to look at the source documentation in RST or MyST.
Look for the
(target)= syntax or
:name: on a directive.
MyST will warn you in the console if your target is not found.
You can also use the intersphinx package, for example,
parse an intersphinx inventory:
>> intersphinx list https://docs.python.org/3.7 --domain std:doc --includes abc --limit 5 std:doc Abstract Base Classes (library/abc) https://docs.python.org/3.7/library/abc.html std:doc Abstract Base Classes for Containers (library/collections.abc) https://docs.python.org/3.7/library/collections.abc.html
Use the target in the parenthesis, which would be
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. As with any other link, you can either follow a
<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)
Finding and formatting the page title
To find the page title, browse Wikipedia and copy the last part of the URL, for example:
https://wikipedia.org/wiki/Page_Title. If you do not supply text for the link specifically, then the case of the link will be preserved and shown without the underscores.
Usually the page titles resolve properly, so just try guessing when you are writing and then you can check them with the live hover preview.
Note that if the page title has spaces in it, simply replace them with underscores.
Different languages or wikis
There are many different official and unofficial wikis that use the same Wikimedia technology, including subdomains in various languages.
Wikipedia links, like
https://fr.wikipedia.org/wiki/Croissant_(viennoiserie) will work fine out of the box, and point to Croissant (viennoiserie) with the popup still working!
Issues and Pull Requests¶
If you do not include children for the link, then the default text will become
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.
Creating GitHub links to code
GitHub links to code can be generated on the GitHub web application when browsing code and click on the line numbers, then copy the URL. To select multiple lines, click your first line then shift-click to select multiple lines, the URL will be updated to end with
#L4-L6. The structure of the link should look like:
reference will work, however, picking a branch like
main may mean that your code line numbers will change, instead, you may want to go to navigate to a specific git commit or tag, which will show up in the URL.
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) 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:
- Cockett, R. (2022). Future of Research Communication & Collaboration. 10.5281/ZENODO.6476040
- 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
- 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