3

我很高兴地设置

<head>
<base href="http://complex_url_to_local_wiki:port/path/" target="_blank" />
</head>

在我的 IPython html 笔记本(IPython 0.12)的 Markdown 单元格中,以便能够像[wiki documentation](doc.html)Markdown 单元格一样缩写链接。

但这使得保存笔记本变得不可能(保存由 恢复<base href='/'/>)。

有什么(替代)方法可以实现我的目标吗?我知道如何通过使用IPython.core.display.HTML[1] 从 Python 代码生成 URL,但是内联 Markdown 文档中的链接要方便得多

谢谢,

阿尔瓦罗。

[1] 从 Python 生成链接的非最佳解决方案粘贴在下面,以防它对某人有用或您有改进建议

def wurl(x, text="Node {} in wiki",
            baseurl="http://complex_url_to_local_wiki:port/path/{}"):
    """Render a link on a base URL as html."""

    from IPython.core.display import HTML
    url_t = '<a href="{baseurl}" target="_blank">{text}</a>'
    return HTML(url_t.format(baseurl=baseurl.format(x), text=text.format(x)))
4

0 回答 0