为了读者的利益:长答案是肯定的,这很困难,但可能。
GitHub 允许将永久链接内联到 Markdown 文件的文本部分
但是,目前似乎无法直接创建此类永久链接,您必须手动创建它们。如下:
- 显示降价文档
- 在文档上方右键单击文档的缩短SHA
(您也可以使用“历史记录”和有问题的提交)
- 显示提交的差异。
- 在提交上方右键单击 3 个点
...
并选择“查看文件”
- 现在 Mardown 再次出现,但它是永久变体。
- 在文档上方右键单击“Blame”
- 向下滚动到包含要引用的文本的 Markdown 表示的行
- 选择有问题的一行或多行
- 从浏览器的地址栏中复制 URL
- 将 URL 粘贴到问题等中。
- 此步骤仅在问题中需要:在 URL 中替换
/blame/
为/blob/
在问题的预览中,您将看到预期的对 Markdown 文本部分的直接引用。
/blob/
-变体的缺点
如果单击 URL,您会在浏览器中看到完整的 Markdown,文本部分未按预期标记。
这是 GitHub 如何处理这些 URL 的限制。
/blame/
-变体的缺点
由于所有这些注释和 Markdown 的非渲染,它是完全不可读的。
例子
请注意,我必须克隆此示例才能创建问题:
https://github.com/hilbix/learn.github.com/blob/gh-pages/README.md
https://github.com/hilbix/learn.github.com/commit/38034b3aee7f4fb7f46e94b3f9c2b3d3554291ba
https://github.com/hilbix/learn.github.com/blob/38034b3aee7f4fb7f46e94b3f9c2b3d3554291ba/README.md
https://github.com/hilbix/learn.github.com/blame/38034b3aee7f4fb7f46e94b3f9c2b3d3554291ba/README.md
https://github.com/hilbix/learn.github.com/blame/38034b3aee7f4fb7f46e94b3f9c2b3d3554291ba/README.md#L20-L23
https://github.com/github/learn.github.com/blob/38034b3aee7f4fb7f46e94b3f9c2b3d3554291ba/README.md#L20-L23
结果:https ://github.com/hilbix/learn.github.com/issues/1
这是进入问题的:
https://github.com/hilbix/learn.github.com/blob/38034b3aee7f4fb7f46e94b3f9c2b3d3554291ba/README.md#L20-L23
see https://stackoverflow.com/a/57202063/490291
这呈现为类似
learn.github.com/README.md
Lines 20 to 23 in 38034b3
$ git clone https://github.com/github/learn.github.com
$ cd learn.github.com
$ script/bootstrap
$ jekyll --server
see https://stackoverflow.com/a/57202063/490291
这是所创建问题的完整 HTML(抱歉,我也没有设法复制 CSS):
<td class="d-block comment-body markdown-body js-comment-body">
<p></p><div class="border rounded-1 my-2">
<div class="f6 px-3 py-2 lh-condensed border-bottom bg-gray-light">
<p class="mb-0 text-bold">
<a href="https://github.com/hilbix/learn.github.com/blob/38034b3aee7f4fb7f46e94b3f9c2b3d3554291ba/README.md#L20-L23">learn.github.com/README.md</a>
</p>
<p class="mb-0 text-gray-light">
Lines 20 to 23
in
<a data-pjax="true" class="commit-tease-sha" href="/hilbix/learn.github.com/commit/38034b3aee7f4fb7f46e94b3f9c2b3d3554291ba">38034b3</a>
</p>
</div>
<div itemprop="text" class="blob-wrapper blob-wrapper-embedded data">
<table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8">
<tbody><tr class="border-0">
<td id="L20" class="blob-num border-0 px-3 py-0 bg-white js-line-number" data-line-number="20"></td>
<td id="LC20" class="blob-code border-0 px-3 py-0 bg-white blob-code-inner js-file-line"> <span class="pl-s1">$ git clone https://github.com/github/learn.github.com</span> </td>
</tr>
<tr class="border-0">
<td id="L21" class="blob-num border-0 px-3 py-0 bg-white js-line-number" data-line-number="21"></td>
<td id="LC21" class="blob-code border-0 px-3 py-0 bg-white blob-code-inner js-file-line"> <span class="pl-s1">$ <span class="pl-c1">cd</span> learn.github.com</span> </td>
</tr>
<tr class="border-0">
<td id="L22" class="blob-num border-0 px-3 py-0 bg-white js-line-number" data-line-number="22"></td>
<td id="LC22" class="blob-code border-0 px-3 py-0 bg-white blob-code-inner js-file-line"> <span class="pl-s1">$ script/bootstrap</span> </td>
</tr>
<tr class="border-0">
<td id="L23" class="blob-num border-0 px-3 py-0 bg-white js-line-number" data-line-number="23"></td>
<td id="LC23" class="blob-code border-0 px-3 py-0 bg-white blob-code-inner js-file-line"> <span class="pl-s1">$ jekyll --server</span> </td>
</tr>
</tbody></table>
</div>
</div>
<p></p>
<p>see <a rel="nofollow" href="https://stackoverflow.com/a/57202063/490291">https://stackoverflow.com/a/57202063/490291</a></p>
</td>