diff --git a/modules/purchase_trade/process_documentation.py b/modules/purchase_trade/process_documentation.py index 87b39cf..cb591fc 100644 --- a/modules/purchase_trade/process_documentation.py +++ b/modules/purchase_trade/process_documentation.py @@ -104,9 +104,10 @@ def _inline(markdown, current_file): else: parts.append(label) elif resolved.endswith('.md'): - parts.append('%s' % ( - html.escape(_anchor(resolved), quote=True), label)) - elif resolved.startswith(('#', 'http://', 'https://', 'mailto:')): + parts.append(_internal_link(_anchor(resolved), label)) + elif resolved.startswith('#'): + parts.append(_internal_link(resolved.lstrip('#'), label)) + elif resolved.startswith(('http://', 'https://', 'mailto:')): parts.append('%s' % ( html.escape(resolved, quote=True), label)) else: @@ -167,10 +168,16 @@ def _markdown_to_html(markdown, current_file): if current_file != 'README.md': body.insert( - 0, '
') + 0, '%s
' % _internal_link('doc-README-md', 'Back to index')) return '\n'.join(body) +def _internal_link(anchor, label): + anchor = html.escape(anchor, quote=True) + return '%s' % ( + anchor, anchor, label) + + def _render_table(lines, current_file): rows = [ [cell.strip() for cell in line.strip('|').split('|')] @@ -242,6 +249,20 @@ HTML_TEMPLATE = '''