GitHub评论的原始Markdown查看

20
4个回答

13

只需在以下URL中替换用户名、仓库名和问题编号:

https://api.github.com/repos/USERNAME/REPONAME/issues/NUMBER/comments

这里有一个例子。


2
为了快速参考,您可以通过将以下内容粘贴到浏览器控制台中来获取第n个评论的正文(即markdown):await fetch('https://api.github.com/repos/:username/:reponame/issues/:issue_id/comments').then(resp => resp.json()).then(comments => comments[n].body) - Christian Reall-Fluharty

5

首先,第一篇文章是关于实际问题本身的,无法访问,但可以通过GitHub issue API获得:

https://api.github.com/repos/jashkenas/backbone/issues/3857/comments

那个列表只有3条评论,因为第一篇文章不是评论。
这个问题本身有一个格式化的正文:

https://api.github.com/repos/jashkenas/backbone/issues/3857

那将返回:

  "body": "In Safari , pass a path using unicode string to `navigate` method  like this\r\n\r\n```js\r\nBackbone.history.navigate('/city/北京',{trigger:true});\r\n```\r\nThe hash is incorrect. It output\r\n\r\n```js\r\nlocation.hash\r\n//> #/city/%17%AC\r\n```\r\n\r\nI tracked the code, it caused by `_updateHash` method.\r\n\r\nThe call stack created by  `History.prototype.navigate` method like this\r\n\r\n* navigate\r\n   -  decodeFragment\r\n   - _updateHash\r\n\r\nThe fragment passed to `_updateHash`,  was decoded by `decodeFragment`, so the hash was incorrect。\r\n\r\nI also searched the commit history, the `decodeFragment` added in \"1.2.0\"\r\n\r\nPS: My english is not good, although I am trying to improve\r\n\r\n",

那不是 完全 的 Markdown:

    In Safari , pass a path using unicode string to `navigate` method  like this

```js\r\nBackbone.history.navigate('/city/北京',{trigger:true});
```\r\nThe hash is incorrect. It output

```js\r\nlocation.hash
//> #/city/%17%AC
```

I tracked the code, it caused by `_updateHash` method.

The call stack created by  `History.prototype.navigate` method like this

* navigate
   -  decodeFragment
   - _updateHash
The fragment passed to `_updateHash`,  was decoded by `decodeFragment`, so the hash was incorrect。
I also searched the commit history, the `decodeFragment` added in \"1.2.0\"
PS: My english is not good, although I am trying to improve

在这个问题中,第二条评论有两张图片,所以那些花哨的效果不是标记语言。

https://cloud.githubusercontent.com/assets/516562/11164567/62f9ddf6-8b2f-11e5-8aa8-631c1aa84422.gif

https://cloud.githubusercontent.com/assets/516562/11164567/62f9ddf6-8b2f-11e5-8aa8-631c1aa84422.gif

[https://jsfiddle.net/leexiaosi/uyp3o6ek/](https://jsfiddle.net/leexiaosi/uyp3o6ek/)

**notice!!!** : please open in safari.

### the record of safari
![safari](https://cloud.githubusercontent.com/assets/516562/11164567/62f9ddf6-8b2f-11e5-8aa8-631c1aa84422.gif)

### the record of chrome
![chrome](https://cloud.githubusercontent.com/assets/516562/11164583/c66d1b82-8b2f-11e5-9d88-ecba16ae6167.gif)

我想这就是我能得到的最好的结果了。 - duffn

4

您可以使用“引用回复”(在单击评论右上角的三个点后找到)查看原始的Markdown。

这是您要求的评论的开头:

In Safari , pass a path using unicode string to navigate method like this

Backbone.history.navigate('/city/北京',{trigger:true});

The hash is incorrect. It output

location.hash
//> #/city/%17%AC

...


这对于原帖提到的评论有效,但对于我在https://github.com/VSpaceCode/VSpaceCode/issues/173#issuecomment-776388616中无效。 - user21952-is-a-great-name
你说得对,它没有捕捉到 kbd 标签: <kbd>q</kbd> - JBallin

3

现在可能有点晚了。但是我可以这样做(至少在Firefox中)。

我假设您的意图是复制评论的格式。

这不是一个完美的解决方案,但由于GitHub支持在评论中使用HTML标签,这将完全有效。

  1. 右键单击要复制的评论顶部的某个位置。
  2. 检查元素
  3. 在检查元素框中,您会发现一行距离高亮线几行的代码:

    <td class="d-block comment-body markdown-body js-comment-body">

  4. 右键单击具有上述代码的行

  5. 选择复制>内部HTML

现在,您可以将其粘贴到评论框中,预览它,您将能够看到相同的格式,或者使用在线HTML转MD转换器


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