如何访问 GitHub wiki 页面的原始 Markdown 文档?

3

我阅读了一篇博客文章,介绍了如何访问GitHub中的原始内容:

This is not entirely obvious (at least it wasn’t for me), but since Github wikis are actually backed by a proper Git repo, I figured it should be possible to access the raw markdown for a page by using Github’s https://raw.github.com/ style URLs.

After some minor trial/error, it turns out to be very predictable (as many things in github):

https://raw.github.com/wiki/[user]/[project]/[page].md
我有一个仓库mbigras/hello-world,其中包含一个维基页面mbigras/hello-world/wiki/foobar。因此,根据上述模式,以下内容应该有效:
https://raw.github.com/wiki/mbigras/hello-world/foobar.md

似乎GitHub已更改其路由如下所示:
$ curl https://raw.github.com/wiki/mbigras/hello-world/foobar.md
$ curl -Is https://raw.github.com/wiki/mbigras/hello-world/foobar.md 2>&1 | head -n 2
HTTP/1.1 301 Moved Permanently
Location: https://raw.githubusercontent.com/wiki/mbigras/hello-world/foobar.md
$ curl -L https://raw.github.com/wiki/mbigras/hello-world/foobar.md
{
  "foo": "bar",
  "cat": "dog",
  "red": "hat"
}

因此,新的模式似乎是:

https://raw.githubusercontent.com/wiki/[user]/[project]/[page].md

GitHub是否发布有关如何访问wiki页面的原始markdown源代码的文档?

这似乎不再起作用了 - 2018年2月 - Federico
已修复 -- 请参见下文 - Alec the Geek
2个回答

4

GitHub是否发布有关如何访问wiki页面的原始markdown源的文档?

是的,在2010年,GitHub在一篇博客中记录了如何导出Wiki。

每个Wiki都是一个Git存储库,因此您可以像任何其他内容一样推送和拉取它们。每个Wiki都尊重与来源存储库相同的权限。只需在URL中为任何存储库名称添加“.wiki”,即可开始使用。

在您的mbigras / hello-world案例中,命令应为:

git clone https://github.com/mbigras/hello-world.wiki.git

1
截至2019年2月,这个有效。
wget https://raw.githubusercontent.com/wiki/<username>/<repo-name>/<page>.md

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接