mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Added "link outside" and "link inside" classes to reference nodes.
Distinguishes hyperlinks that are outside of current sphinx hierarchy.
This commit is contained in:
parent
482720cf65
commit
a4fee15556
@ -168,13 +168,26 @@ class CitationReferences(Transform):
|
||||
refnode += nodes.Text('[' + cittext + ']')
|
||||
citnode.parent.replace(citnode, refnode)
|
||||
|
||||
class CategorizeReferences(Transform):
|
||||
"""Categorize references (hyperlinks) as link outside or link inside"""
|
||||
|
||||
default_priority = 619
|
||||
def apply(self):
|
||||
for reference in self.document.traverse(nodes.reference):
|
||||
if reference.hasattr('refuri'):
|
||||
refuri = reference['refuri']
|
||||
if re.match(r"(?:http|https|ftp)://", refuri):
|
||||
classes = ("link", "outside")
|
||||
else:
|
||||
classes = ("link", "inside")
|
||||
reference["classes"].extend(classes)
|
||||
|
||||
class SphinxStandaloneReader(standalone.Reader):
|
||||
"""
|
||||
Add our own transforms.
|
||||
"""
|
||||
transforms = [CitationReferences, DefaultSubstitutions, MoveModuleTargets,
|
||||
HandleCodeBlocks, SortIds]
|
||||
HandleCodeBlocks, SortIds, CategorizeReferences]
|
||||
|
||||
def get_transforms(self):
|
||||
return standalone.Reader.get_transforms(self) + self.transforms
|
||||
|
@ -147,7 +147,8 @@ div.sphinxsidebar input {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
/* -- body styles ----------------------------------------------------------- */
|
||||
|
||||
/* -- hyperlink styles ------------------------------------------------------ */
|
||||
|
||||
a {
|
||||
color: {{ theme_linkcolor }};
|
||||
@ -163,6 +164,48 @@ a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
div.toctree-wrapper a,
|
||||
div.toctree-wrapper a:visited,
|
||||
div#indices-and-tables a,
|
||||
div#indices-and-tables a:visited,
|
||||
div.sphinxsidebar a,
|
||||
div.sphinxsidebar a:visited,
|
||||
div.related a,
|
||||
div.related a:visited {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
div.toctree-wrapper a:hover,
|
||||
div#indices-and-tables a:hover,
|
||||
div.sphinxsidebar a:hover,
|
||||
div.related a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
a.link.outside {
|
||||
text-decoration: none;
|
||||
border-bottom: 1px dashed {{ theme_linkcolor }};
|
||||
}
|
||||
|
||||
a.link.outside:hover {
|
||||
text-decoration: none;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
/* To distinguish between internal & external references uncomment following */
|
||||
/*
|
||||
a.reference,
|
||||
a.reference em {
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
a.reference.internal em {
|
||||
font-style: italic;
|
||||
}
|
||||
*/
|
||||
|
||||
/* -- body styles ----------------------------------------------------------- */
|
||||
|
||||
div.body h1,
|
||||
div.body h2,
|
||||
div.body h3,
|
||||
|
Loading…
Reference in New Issue
Block a user