我经常通过#LURI中的param 链接到GitHub源代码.
例如:https://github.com/github/learn.github.com/blob/gh-pages/episodes.yaml#L1
但是有没有办法链接到Markdown文件中的行?
例如https://github.com/github/learn.github.com/blob/gh-pages/README.md#L1 (不起作用!)
我知道我可以链接到'部分',但线条要好得多!
例如https://github.com/github/learn.github.com/blob/gh-pages/README.md#learngithubcom
lul*_*ala 18
由于目前无法实现,我采用下一个最佳选择:使用blame然后突出显示这些行,例如https://github.com/rails/rails/blame/master/guides/source/configuring.md#L166
Dan*_*ein 18
?plain=12021 年 6 月 30 日宣布,现在有一个禁用 Markdown 渲染的参数:
现在,附加
?plain=1到任何 Markdown 文件的 url 将显示该文件而不进行渲染。与其他代码文件一样,它也会显示行号,并可用于将其他用户链接到特定的一行或多行。例如,追加?plain=1#L52将突出显示纯文本 Markdown 文件的第 52 行。
听起来您可能想使用行号链接到渲染文档中的某个点。这仍然是不可能的,也不是 Markdown 渲染的标准功能来添加这样的行号锚点。
为了读者的利益:长答案是肯定的,这很困难,但可能。
但是目前似乎无法直接创建此类永久链接,您必须手动创建它们。如下:
...并选择“查看文件”/blame/为/blob/ 在问题的预览中,您将看到预期的 Markdown 文本部分的直接引用。
/blob/-variant如果单击 URL,您会在浏览器中看到完整的 Markdown,文本部分未按预期标记。
这是 GitHub 如何处理这些 URL 的限制。
/blame/-variant由于所有这些注释和 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/issues/1
这是进入问题:
https://github.com/hilbix/learn.github.com/blob/38034b3aee7f4fb7f46e94b3f9c2b3d3554291ba/README.md#L20-L23
see /sf/answers/4004144441/
Run Code Online (Sandbox Code Playgroud)
这呈现为类似
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 /sf/answers/4004144441/
Run Code Online (Sandbox Code Playgroud)
这是所创建问题的完整 HTML(抱歉,我也没有设法复制 CSS):
https://github.com/hilbix/learn.github.com/blob/38034b3aee7f4fb7f46e94b3f9c2b3d3554291ba/README.md#L20-L23
see https://stackoverflow.com/a/57202063/490291
Run Code Online (Sandbox Code Playgroud)