diff --git a/README.md b/README.md
index a72bb5f..3a20bdc 100644
--- a/README.md
+++ b/README.md
@@ -165,7 +165,9 @@ This extension adds custom roles that can be used in rST.
Currently implemented:
-- `spellexception` - Includes the provided text in ``, which makes it possible to exclude it from a spell checker.
+- `spellexception` - Includes the provided text in ``, which makes it possible to exclude it from a spelling checker.
+- `monoref` - Renders the provided reference in code-style, which excludes the link text from the spelling checker.
+ You can provide either just the link (for example, ``:monoref:`www.example.com` ``, which results in `www.example.com` as the link text and `https://www.example.com` as the link URL) or a separate link text and URL (for example, ``:monoref:`xyzcommand ` ``).
### Config options
diff --git a/custom-rst-roles/__init__.py b/custom-rst-roles/__init__.py
index a552f0e..e70ed04 100644
--- a/custom-rst-roles/__init__.py
+++ b/custom-rst-roles/__init__.py
@@ -1,4 +1,5 @@
from docutils import nodes
+import re
def spellexception_role(
@@ -10,7 +11,31 @@ def spellexception_role(
return [node], []
+def literalref_role(
+ name, rawtext, text, lineno, inliner, options=None, content=None
+):
+
+ findURL = re.compile(r"^(.+)<(.+)>$")
+ m = findURL.match(text)
+
+ if m is not None:
+ linktext = m.groups()[0]
+ linkurl = m.groups()[1]
+ else:
+ linktext = text
+ linkurl = text
+
+ if linkurl.find("://") < 0:
+ linkurl = "https://" + linkurl
+
+ node = nodes.reference("", "", internal=False, refuri=linkurl)
+ node.append(nodes.literal(text=linktext))
+
+ return [node], []
+
+
def setup(app):
app.add_role("spellexception", spellexception_role)
+ app.add_role("literalref", literalref_role)
return
diff --git a/setup.cfg b/setup.cfg
index 9a19607..b0350ce 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = lxd-sphinx-extensions
-version = 0.0.14
+version = 0.0.15
author = Ruth Fuchss
author_email = ruth.fuchss@canonical.com
description = A collection of Sphinx extensions used in LXD