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://')
|
||||
):
|
||||
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,
|
||||
description=html.escape(word)))
|
||||
else:
|
||||
@ -435,6 +435,7 @@ def render_text_tokens(tokens, acc, headline, graph):
|
||||
|
||||
elif isinstance(chunk, Link):
|
||||
link_target = chunk.value
|
||||
is_internal_link = True
|
||||
if link_target.startswith('id:'):
|
||||
link_target = './' + link_target[3:] + '.node.html'
|
||||
elif link_target.startswith('./') or link_target.startswith('../'):
|
||||
@ -456,6 +457,7 @@ def render_text_tokens(tokens, acc, headline, graph):
|
||||
else:
|
||||
link_target = './' + target_headline.id + '.node.html'
|
||||
else:
|
||||
is_internal_link = False
|
||||
if not (
|
||||
link_target.startswith('https://')
|
||||
or link_target.startswith('http://')
|
||||
@ -467,8 +469,9 @@ def render_text_tokens(tokens, acc, headline, graph):
|
||||
if description is None:
|
||||
description = chunk.value
|
||||
|
||||
acc.append('<a href="{}">{}</a>'.format(
|
||||
acc.append('<a href="{}" class="{}" >{}</a>'.format(
|
||||
html.escape(link_target),
|
||||
'internal' if is_internal_link else 'external',
|
||||
html.escape(description),
|
||||
))
|
||||
# else:
|
||||
|
@ -300,6 +300,12 @@ tr.__table-separator {
|
||||
a {
|
||||
color: #00fdf2;
|
||||
}
|
||||
a.internal::before {
|
||||
content: '{ ';
|
||||
}
|
||||
a.internal::after {
|
||||
content: ' }';
|
||||
}
|
||||
h1,h2,h3,h4,h5,h6 {
|
||||
color: #f7da4a;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user