如何在Databricks中创建指向Markdown标题的链接?

huangapple go评论57阅读模式
英文:

How to create a link to a markdown header in databricks?

问题

%md
我想引用来自另一个markdown单元格的databricks工作区内的一个markdown单元格。
所引用的单元格如下:

%md
business questions

被引用的单元格如下:

%md

Buisiness Questions

如果我点击链接,它会将我导航到主页,因为它无法找到链接。

根据文档 ,我已经成功引用了该单元格,使用HTML超链接标记。然而,工作区、笔记本和单元格ID都是硬编码的,所以每次更改都需要适应。

%md
business questions

如何在不硬编码任何ID的情况下链接markdown标题?

英文:

I would like to reference a markdown cell inside a databricks workspace from another markdown cell.
The reference cell is the following:

%md
[business questions](#buisiness-questions)

The referenced cell look like this:

%md
# Buisiness Questions

If I click on the link then it will navigate me to the home page because it can not find the link.

I have managed to reference the cell according to documentation using HTML hyperlink tag. However, the workspace and notebook, and cell IDs are hard-coded so anytime it is changed, adaptation is necessary.

%md
<a href="https://adb-[some_id].azuredatabricks.net/?o=[some_id]#notebook/[some_id]/command/[some_id]">business questions</a>

How to link a markdown header without hardcoding any IDs?

答案1

得分: 0

正如 @Saideep Arikontham 所提到的,目前没有办法以程序方式检索单元格的URL。幸运的是,如果单元格的顺序或内容发生更改,单元格的URL也不会更改。它还不会在工作区与集群分离或重新启动时更改。

因此,可以安全地使用超链接标记来引用单元格。

%md
<a href="https://adb-[some_id].azuredatabricks.net/?o=[some_id]#notebook/[some_id]/command/[some_id]">business questions</a>

注意: 请注意,如果单元格被删除,则单元格URL也将被删除。因此,可能需要进行单元格URL的适应。有关更多信息,请参阅 此处

英文:

As @Saideep Arikontham mentioned there is no way to retrieve the cell's URL programmatically. Fortunately, the cell's URL is not changed if the cell's order or content changes. It will also not change if the workspace is detached from the cluster or restarted.

Therefore it is safe to use the hyperlink tag for referencing the cell.

%md
&lt;a href=&quot;https://adb-[some_id].azuredatabricks.net/?o=[some_id]#notebook/[some_id]/command/[some_id]&quot;&gt;business questions&lt;/a&gt;

NOTE: Be aware that if the cell is deleted then the cell URL is also removed. So cell URL adaptation would be necessary. More information about identifiers.

huangapple
  • 本文由 发表于 2023年2月6日 21:13:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/75361778.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定