Render * Target links.

This commit is contained in:
Sergio Martínez Portela 2022-10-23 18:28:08 +02:00
parent ce8fd431b6
commit 4d3997bce1

View File

@ -288,6 +288,13 @@ def main(src_top, dest_top):
continue
logging.info("Updated all in {:.2f}s".format(time.time() - t0))
def get_headline_with_name(target_name, doc):
target_name = target_name.strip()
for headline in doc.getAllHeadlines():
if headline.title.get_text().strip() == target_name:
return headline
return None
def print_tree(tree, indentation=0, headline=None):
# if headline and headline.id != INDEX_ID:
@ -416,7 +423,11 @@ def render_text_tokens(tokens, acc, headline, graph):
elif link_target.startswith('git://'):
logging.warn('Not implemented `git://`. Used on {}'.format(link_target))
elif link_target.startswith('* '):
logging.warn('Not implemented `* Headline` links. Used on {}'.format(link_target))
target_headline = get_headline_with_name(link_target.lstrip('* '), headline.doc)
if target_headline is None:
logging.warn('No headline found corresponding to {}. On file {}'.format(link_target, headline.doc.path))
else:
link_target = './' + target_headline.id + '.node.html'
else:
if not (
link_target.startswith('https://')