Links and other
m.css plugins make linking to external content almost too easy. If your website is about coding, chances are quite high that you will be linking to repositories, documentation or bugtrackers. Manually copy-pasting links from the browser gets quite annoying after a while and also doesn’t really help with keeping the reST sources readable.
Because not everybody needs to link to all services provided here, the functionality is separated into a bunch of separate plugins, each having its own requirements.
Stylable links
For Pelican, download the m/link.py file, put it
including the m/
directory into one of your PLUGIN_PATHS
and add
m.link
package to your PLUGINS
in pelicanconf.py
. For the
Python doc theme, it’s enough to just list it in PLUGINS
:
PLUGINS += ['m.link']
The :link:
interpreted text role is an alternative to the builtin
reST link syntax, but with an ability to specify
additional CSS classes. At the moment the plugin knows only external URLs.
GitHub
For Pelican, download the m/gh.py file, put it
including the m/
directory into one of your PLUGIN_PATHS
and add
m.gh
package to your PLUGINS
in pelicanconf.py
. For the Python
doc theme, it’s enough to just list it in PLUGINS
:
PLUGINS += ['m.gh']
Use the :gh:
interpreted text role for linking. The plugin mimics how
GitHub Flavored Markdown
parses inter-site links, with some extensions on top. In addition to well-known
references to commits and issues/PRs via @
and #
, $
is for linking
to a tree (or file in given tree) and ^
is for linking to a tag/release. If
your link target doesn’t contain any of these characters and contains more than
one slash, the target is simply prepended with https://github.com/
.
Link text is equal to link target for repository, commit and issue/PR links,
otherwise the full expanded URL is used. Similarly to builtin linking
functionality, if you want a custom text for a link, use the
:gh:`link text <link-target>`
syntax. It’s also possible to add custom
CSS classes by deriving the role and adding the :class:
option.
OpenGL functions and extensions
For Pelican, download the m/gl.py file, put it
including the m/
directory into one of your PLUGIN_PATHS
and add
m.gl
package to your PLUGINS
in pelicanconf.py
. For the Python
doc theme, it’s enough to just list it in PLUGINS
:
PLUGINS += ['m.gl']
Use the :glfn:
interpreted text role for linking to functions,
:glext:
for linking to OpenGL / OpenGL ES extensions, :webglext:
for linking to WebGL extensions and :glfnext:
for linking to extension
functions. In the link target the leading gl
prefix of functions and the
leading GL_
prefix of extensions is prepended automatically.
Link text is equal to full function name including the gl
prefix and
()
for functions, equal to extension name or equal to extension function
link, including the vendor suffix. For :glfn:
, :glext:
and
:webglext:
it’s possible to specify alternate link text using the
well-known syntax. Adding custom CSS classes can be done by deriving the role
and adding the :class:
option.
Vulkan functions and extensions
For Pelican, download the m/vk.py file, put it
including the m/
directory into one of your PLUGIN_PATHS
and add
m.vk
package to your PLUGINS
in pelicanconf.py
. For the Python
doc theme, it’s enough to just list it in PLUGINS
:
PLUGINS += ['m.vk']
Use the :vkfn:
interpreted text role for linking to functions,
:vktype:
for linking to types and :vkext:
for linking to
extensions. In the link target the leading vk
prefix of functions, Vk
prefix of types and the leading VK_
prefix of extensions is prepended
automatically.
Link text is equal to full function name including the vk
prefix and
()
for functions, Vk
prefix for types or equal to extension name. It’s
possible to specify alternate link text using the well-known syntax.
Doxygen documentation
For Pelican, download the m/dox.py file, put it
including the m/
directory into one of your PLUGIN_PATHS
and add
m.dox
package to your plugins in pelicanconf.py
. The plugin uses
Doxygen tag files to get a list of linkable symbols and you need to provide
list of tuples containing tag file path, URL prefix, an optional list of
implicitly prepended namespaces and an optional list of CSS classes for each
link in a M_DOX_TAGFILES
configuration value. Example:
PLUGINS += ['m.dox'] M_DOX_TAGFILES = [ ('doxygen/stl.tag', 'https://en.cppreference.com/w/'), ('doxygen/corrade.tag', 'https://doc.magnum.graphics/corrade/', ['Corrade::']), ('doxygen/magnum.tag', 'https://doc.magnum.graphics/magnum/', ['Magnum::'], ['m-text', 'm-flat'])]
For the Python doc theme, the configuration is the same. Tag file paths are
relative to the configuration file location or to PATH
, if specified.
Use the :dox:
interpreted text role for linking to documented symbols.
All link targets understood by Doxygen’s @ref
or @link
commands are
understood by this plugin as well, in addition it’s possible to link to the
documentation index page by specifying the tag file basename w/o extension as
link target. In order to save you some typing, the leading namespace(s)
mentioned in the M_DOX_TAGFILES
setting can be omitted when linking to
given symbol.
Link text is equal to link target in all cases except for pages and sections,
where page/section title is extracted from the tagfile. It’s possible to
specify custom link title using the :dox:`link title <link-target>`
syntax. If a symbol can’t be found, a warning is printed to output and link
target is rendered in a monospace font (or, if custom link title is specified,
just the title is rendered, as normal text). You can append #anchor
to
link-target
to link to anchors that are not present in the tag file (such
as #details
for the detailed docs or #pub-methods
for jumping straight
to a list of public member functions), the same works for query parameters
starting with ?
. Adding custom CSS classes can be done by deriving the role
and adding the :class:
option.
It’s also possible to add custom CSS classes via a fourth tuple item. For example, to make the links consistent with the Doxygen theme (where documentation links are not underscored, internal doxygen links are bold and external not), you could do this:
PLUGINS += ['m.dox'] M_DOX_TAGFILES = [ ('doxygen/stl.tag', 'https://en.cppreference.com/w/', [], ['m-flat']), ('doxygen/your-lib.tag', 'https://doc.your-lib.com/', ['YourLib::'], ['m-flat', 'm-text', 'm-strong'])]
Abbreviations
While not exactly a link but rather a way to produce correct <abbr>
elements, it belongs here as it shares a similar syntax.
For Pelican, download the m/abbr.py file, put it
including the m/
directory into one of your PLUGIN_PATHS
and add
m.abbr
package to your PLUGINS
in pelicanconf.py
. This plugin
assumes presence of m.htmlsanity.
PLUGINS += ['m.htmlsanity', 'm.abbr']
The plugin overrides the builtin Pelican abbr interpreted text role and makes its syntax consistent with other common roles of reST and m.css.
Use the :abbr:
interpreted text role for creating abbreviations with
title in angle brackets. Adding custom CSS classes can be done by deriving the
role and adding the :class:
option.
File size queries
Okay, this is not a link at all, but — sometimes you might want to display size of a file, for example to tell the users how big the download will be.
For Pelican, ownload the m/filesize.py file, put it
including the m/
directory into one of your PLUGIN_PATHS
and add
m.filesize
package to your PLUGINS
in pelicanconf.py
.
PLUGINS += ['m.filesize']
Use the filesize
interpreted text role to display the size of a file
including units. The filesize-gz
role compresses the file using GZip
first before calculating the size. Adding custom CSS classes can be done by
deriving the role and adding the :class:
option.
Aliases
Site content almost never stays on the same place for extended periods of time and preserving old links for backwards compatibility is a vital thing for user friendliness. This plugin allows you to create a redirect alias URLs for your pages and articles.
For Pelican, download the m/alias.py file, put it
including the m/
directory into one of your PLUGIN_PATHS
and add
m.alias
package to your PLUGINS
in pelicanconf.py
.
PLUGINS += ['m.alias']
Use the :alias:
field to specify one or more locations that should
redirect to your article / page. Each line is treated as one alias, the
locations have to begin with /
and are relative to the Pelican output
directory, each of them contains just a <meta http-equiv="refresh" />
that points to a fully-qualified URL of the article or page.
If the alias ends with /
, the redirector file is saved into index.html
in given directory.
My Article ########## :alias: /2018/05/06/old-version-of-the-article/ /even-older-version-of-the-article.html