如何只从要点嵌入某些行? [英] How to embed only certain lines from a gist?

查看:102
本文介绍了如何只从要点嵌入某些行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Gist让你在网页中嵌入一个要点:

 < script src =https:// gist。 github.com/dyoo/4627246.js\"></script> 

我希望我可以让它显示一个行范围子集。 (使用案例:在一篇论文中写一些博客文章的代码,参考博客文章中讨论这些文章的特定行)。

这可能吗?我无法找到它的记录,但有没有办法做到这一点?






作为我如何思考的例子它可能可以工作,GitHub支持带有行号的URI。例如, $ b $ p $ < ://github.com/twitter/bootstrap/blob/master/docs/base-css.html#L4-L8

我意识到GitHub只显示所有突出显示。而我正在问如何显示来自Gist的特定行。我提到这仅仅是为了举例,我怎么猜测它可能工作。







ps根据to 我如何使用新的gist接口从GitHub gist中嵌入单个文件?,这听起来像是最近这种方式与我所问的方向相反:从一个要点嵌入一个文件的能力最近消失了。我想只显示来自一个文件的某些行。但我想问问。此外,我认为这是一个明显的问题,这就是为什么我发布这个而不是评论现有问题。


解决方案

Gist API不提供任何此类方法来嵌入部分要点。不过,您可以用JavaScript自己完成。
有一个很好的图书馆可以使用:



https://github.com/blairvanderhoof/gist-embed



您可以使用此嵌入部分精华。


Gist lets you embed a gist in a web page:

<script src="https://gist.github.com/dyoo/4627246.js"></script>

I was hoping I could have it display just a line range subset. (Use case: Write some code for a blog post in a single gist. Reference certain lines throughout the blog post discussing those lines.)

Is this possible? I can't find it documented, but is there some way to do it?


As an example of how I thought it might work, GitHub supports URIs with line numbers. For example, the #L4-L8 anchor in this:

https://github.com/twitter/bootstrap/blob/master/docs/base-css.html#L4-L8

I realize GitHub shows all lines with just those lines highlighted. Whereas I'm asking how to show just certain lines from a Gist. I mention this just for-example, how I guessed it might work.


p.s According to How do I embed a single file from a GitHub gist with the new gist interface?, it sounds like this recently moved in the opposite direction from what I'm asking: The ability to embed just one file from a gist recently disappeared. I want to display just certain lines from just one file. But I wanted to ask anyway. Also I think this is a distinct question from that, which is why I posted this instead of commenting the existing question.

解决方案

Gist API doesn't provide any such way to embed part of a gist. However you can do it yourself with javascript in your end. there is a good library you can use:

https://github.com/blairvanderhoof/gist-embed

You can embed parts of a gist with this.

这篇关于如何只从要点嵌入某些行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆