在 Github 中的另一个页面的 header 创建一个 link
Create a link to the header of another page in Github
有谁知道如何创建一个 link 到另一个维基页面的 header 吗?
我知道如果我有一个 header ##Header name
,我可以通过使用 (#header-name)
作为我的 link 在该页面上 link,但是我想从另一个页面 link 到那个 header。这可能吗?
即。我想要 table 的内容可以 link 每个 wiki 页面的 sub-sections 以及页面本身。
编辑:我的意思是除了使用 url link
http://github.com/project/wiki/Wiki-Page#header-name
我测试了 Maxwell 的 "good way" 到 Github 中另一页的 link to the header 在 Edit 1 并且运行良好。
#[crux-ports Installation](/user/crux-ports/blob/master/README.md#installation)
编辑 1:之前完全错了,我只是多读了一点。所以我们在 GitHub Wiki 中也有这种新的支持! (比较新。)
你也可以这样做:
[[ Link text | page_title#header_title ]]
这可能对您更有效!直到因为这个答案 here。您可以看到我使用先决条件 link 执行此操作,您可以看到我的其他 link 以其他方式工作。我是时候做一些更新了!
编辑 1:仍然有用,但绝对不是唯一的方法。
所以我之前回答过一个关于这个的问题,你应该避免GitHub (i.e. https://github.com/user/repo_name/...)
上的绝对links
然而,可以看到一个很好的方法(也是维基内部唯一的方法 编辑 1:完全不是唯一的方法)做你需要的像这样:
[Header link](/user/repository_name/wiki/page_name#title).
不幸的是,Wiki 会支持这种 linking。这将根据 GitHub 更改您的目录页面。你可以看到它会是
https://github.com/(the linkage you want to hit)
我实际上已经开始在我从事 here 的 Wiki 中做类似的事情。在我的侧边栏中,您可以看到我有一个入门页面,然后其中的一个小节是先决条件标题,它将正确地引导人们到达他们需要去的地方。您将能够在任何页面上执行相同的操作。它有点冗长,但值得,因为如果需要,您可以轻松地改变周围的事物。这也是 case-sensitive,因为它会改变它们的位置,因此请确保在您的 link 年龄,页面大小写正确并且您的标题全部小写。
希望对您有所帮助!
您可以 link 到 header,只需将 id 分配给 header。例如,您在名为 Abc 的页面中有 "Extension" header。
# <a id="extension"></a> Extensions
你有另一个页面 "Call center" 并且你想转到 abc 中的扩展,你可以使用参考 linking of markdown 即 "The [extensions][1] are handled by agents"
[1]: url-of-abc/#extension
markdown 为标题生成 slug 并将其转换为 id,示例
# [ topic ][ color ]
将转换为
<h1 id="topic--color" data-line="643" class="code-line">[ topic ][ color ]</h1>
因此,对于link你可以写成[color](#topic--color)
。
如果目标锚点在另一个页面上(假设文件名css.md
),路径相对于当前降价页面,那么你可以把它写成[color](css.md#topic--color)
附加 vscode 中的 slugify 函数
// excerpt from https://github.com/yzhang-gh/vscode-markdown/blob/908d7ba5465a203e4299f346c179211d992ef468/src/util/slugify.ts
const str = '# [ topic ][ color ]';
const slug = encodeURI(
str.trim()
.replace(/\s+/g, "-") // Replace whitespace with -
.replace(/[\]\[\!\'\#$\%\&\'\(\)\*\+\,\.\/\:\;\<\=\>\?\@\\^\_\{\|\}\~\`。,、;:?!…—·ˉ¨‘’“”々~‖∶"'`|〃〔〕〈〉《》「」『』.〖〗【】()[]{}]/g, "") // Remove known punctuators
.replace(/^\-+/, "") // Remove leading -
.replace(/\-+$/, "") // Remove trailing -
);
console.log(slug) // "topic--color"
有谁知道如何创建一个 link 到另一个维基页面的 header 吗?
我知道如果我有一个 header ##Header name
,我可以通过使用 (#header-name)
作为我的 link 在该页面上 link,但是我想从另一个页面 link 到那个 header。这可能吗?
即。我想要 table 的内容可以 link 每个 wiki 页面的 sub-sections 以及页面本身。
编辑:我的意思是除了使用 url link
http://github.com/project/wiki/Wiki-Page#header-name
我测试了 Maxwell 的 "good way" 到 Github 中另一页的 link to the header 在 Edit 1 并且运行良好。
#[crux-ports Installation](/user/crux-ports/blob/master/README.md#installation)
编辑 1:之前完全错了,我只是多读了一点。所以我们在 GitHub Wiki 中也有这种新的支持! (比较新。)
你也可以这样做:
[[ Link text | page_title#header_title ]]
这可能对您更有效!直到因为这个答案 here。您可以看到我使用先决条件 link 执行此操作,您可以看到我的其他 link 以其他方式工作。我是时候做一些更新了!
编辑 1:仍然有用,但绝对不是唯一的方法。
所以我之前回答过一个关于这个的问题,你应该避免GitHub (i.e. https://github.com/user/repo_name/...)
上的绝对links然而,可以看到一个很好的方法(也是维基内部唯一的方法 编辑 1:完全不是唯一的方法)做你需要的像这样:
[Header link](/user/repository_name/wiki/page_name#title).
不幸的是,Wiki 会支持这种 linking。这将根据 GitHub 更改您的目录页面。你可以看到它会是
https://github.com/(the linkage you want to hit)
我实际上已经开始在我从事 here 的 Wiki 中做类似的事情。在我的侧边栏中,您可以看到我有一个入门页面,然后其中的一个小节是先决条件标题,它将正确地引导人们到达他们需要去的地方。您将能够在任何页面上执行相同的操作。它有点冗长,但值得,因为如果需要,您可以轻松地改变周围的事物。这也是 case-sensitive,因为它会改变它们的位置,因此请确保在您的 link 年龄,页面大小写正确并且您的标题全部小写。
希望对您有所帮助!
您可以 link 到 header,只需将 id 分配给 header。例如,您在名为 Abc 的页面中有 "Extension" header。
# <a id="extension"></a> Extensions
你有另一个页面 "Call center" 并且你想转到 abc 中的扩展,你可以使用参考 linking of markdown 即 "The [extensions][1] are handled by agents"
[1]: url-of-abc/#extension
markdown 为标题生成 slug 并将其转换为 id,示例
# [ topic ][ color ]
将转换为
<h1 id="topic--color" data-line="643" class="code-line">[ topic ][ color ]</h1>
因此,对于link你可以写成[color](#topic--color)
。
如果目标锚点在另一个页面上(假设文件名css.md
),路径相对于当前降价页面,那么你可以把它写成[color](css.md#topic--color)
附加 vscode 中的 slugify 函数
// excerpt from https://github.com/yzhang-gh/vscode-markdown/blob/908d7ba5465a203e4299f346c179211d992ef468/src/util/slugify.ts
const str = '# [ topic ][ color ]';
const slug = encodeURI(
str.trim()
.replace(/\s+/g, "-") // Replace whitespace with -
.replace(/[\]\[\!\'\#$\%\&\'\(\)\*\+\,\.\/\:\;\<\=\>\?\@\\^\_\{\|\}\~\`。,、;:?!…—·ˉ¨‘’“”々~‖∶"'`|〃〔〕〈〉《》「」『』.〖〗【】()[]{}]/g, "") // Remove known punctuators
.replace(/^\-+/, "") // Remove leading -
.replace(/\-+$/, "") // Remove trailing -
);
console.log(slug) // "topic--color"