Visually identify internal links.
This commit is contained in:
parent
2eab1b4351
commit
955dc433df
@ -424,7 +424,7 @@ def render_text_tokens(tokens, acc, headline, graph):
|
|||||||
or word.startswith('ftps://')
|
or word.startswith('ftps://')
|
||||||
):
|
):
|
||||||
raise Exception('Is this a link? {} (on {})\nLine: {}\nChunks: {}'.format(word, headline.doc.path, line, chunks))
|
raise Exception('Is this a link? {} (on {})\nLine: {}\nChunks: {}'.format(word, headline.doc.path, line, chunks))
|
||||||
line_chunks.append('<a href="{url}">{description}</a>'
|
line_chunks.append('<a href="{url}" class="external">{description}</a>'
|
||||||
.format(url=word,
|
.format(url=word,
|
||||||
description=html.escape(word)))
|
description=html.escape(word)))
|
||||||
else:
|
else:
|
||||||
@ -435,6 +435,7 @@ def render_text_tokens(tokens, acc, headline, graph):
|
|||||||
|
|
||||||
elif isinstance(chunk, Link):
|
elif isinstance(chunk, Link):
|
||||||
link_target = chunk.value
|
link_target = chunk.value
|
||||||
|
is_internal_link = True
|
||||||
if link_target.startswith('id:'):
|
if link_target.startswith('id:'):
|
||||||
link_target = './' + link_target[3:] + '.node.html'
|
link_target = './' + link_target[3:] + '.node.html'
|
||||||
elif link_target.startswith('./') or link_target.startswith('../'):
|
elif link_target.startswith('./') or link_target.startswith('../'):
|
||||||
@ -456,6 +457,7 @@ def render_text_tokens(tokens, acc, headline, graph):
|
|||||||
else:
|
else:
|
||||||
link_target = './' + target_headline.id + '.node.html'
|
link_target = './' + target_headline.id + '.node.html'
|
||||||
else:
|
else:
|
||||||
|
is_internal_link = False
|
||||||
if not (
|
if not (
|
||||||
link_target.startswith('https://')
|
link_target.startswith('https://')
|
||||||
or link_target.startswith('http://')
|
or link_target.startswith('http://')
|
||||||
@ -467,8 +469,9 @@ def render_text_tokens(tokens, acc, headline, graph):
|
|||||||
if description is None:
|
if description is None:
|
||||||
description = chunk.value
|
description = chunk.value
|
||||||
|
|
||||||
acc.append('<a href="{}">{}</a>'.format(
|
acc.append('<a href="{}" class="{}" >{}</a>'.format(
|
||||||
html.escape(link_target),
|
html.escape(link_target),
|
||||||
|
'internal' if is_internal_link else 'external',
|
||||||
html.escape(description),
|
html.escape(description),
|
||||||
))
|
))
|
||||||
# else:
|
# else:
|
||||||
|
@ -300,6 +300,12 @@ tr.__table-separator {
|
|||||||
a {
|
a {
|
||||||
color: #00fdf2;
|
color: #00fdf2;
|
||||||
}
|
}
|
||||||
|
a.internal::before {
|
||||||
|
content: '{ ';
|
||||||
|
}
|
||||||
|
a.internal::after {
|
||||||
|
content: ' }';
|
||||||
|
}
|
||||||
h1,h2,h3,h4,h5,h6 {
|
h1,h2,h3,h4,h5,h6 {
|
||||||
color: #f7da4a;
|
color: #f7da4a;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user