How to quote code in a Mardkown GitHub Gist - github

In a markdown file in a Gist, how do you quote some lines of code that are in a GitHub project?
If I was writing a Gist to try and explain how something works, I might have a block of text, then quote some code. I don't want to cut and paste the code in, I just want to quote some lines of code in a GitHub project. I am sure I have seen this done, but can't find an explanation of how to do it.
For example:
This algorithm makes use of Dijkstra's topological sort algorithm:
100: Result myFancyPantsAlgorithm(Blah blah) {
101: youGetTheIdea();
102: }

It is not possible to embed GitHub code snippets from Repositories.
What you might have seen is having a gist embedded in a "normal" website which is possible because GitHub provides a script to embed gists.
The script tag is (un)fortunately not whitelisted to be used in GitHub Flavored Markdown, so it is not possible to embed a gist in markdown.
A way to get around this would be to set a gh-page up, where you are able to embed a Gist as this SO-question shows. But then you're still not referencing to any live codebase.
So the answer to your question is: this is not possible, wether by embedding code from a repository nor by taking a detour via using gists.

Related

How to get no frame on a table in AsciiDoc on GitHub

I want to make a table in AsciiDoc on GitHub with no frame. My reading of the documentation is that this should work:
[frame="none",options="header"]
|===
| Foo | Bar
| Widget | Gadget
|===
Yet it renders with a frame:
That frame="none" setting should do it. But it doesn't. I try it without quotes and its the same. The options="header" works fine, so I know the interpreter is seeing the line in brackets and taking some action.
Is it possible that GitHub runs some version of AsciiDoc that is not full featured? If so, is there a site with the details of what does and doesn't work?
Note--this is on our internal corporate instance of GitHub Enterprise, so we may be some versions out of date, or not have some plug-in installed. Is there a special plug-in that does the trick? I don't admin the platform, so is there a way I can check versions and plug-ins in any given GitHub platform as an ordinary developer?
We use AsciiDoc pervasively as our GitHub Wiki language, so changing to another one that does tables better is not an option.
All help appreciated!
GitHub runs an official Asciidoctor to provide a nice rendering. However, they also run the generated HTML and CSS through a filtering process to prevent security issues. During that process, they strip off custom class names from a variety (if not all) elements (I don't know the exact details).
Running asciidoctor on your sample document shows a table that looks like this:
<table class="tableblock frame-none grid-all stretch">
Whereas their process results in a table that looks like:
<table>
From GitHub's perspective, those kinds of changes mean that tables look the same everywhere on the site.
If you need frameless tables, you'll probably find using GitHub Pages a lot easier because you can use custom (or asciidoctor-provided) CSS in that context.

Mermaid syntax error on trying render a diagram on Github .md file

I've followed this MermaId tutorial but when I try put into my .md file on Github an error is raised:
This works perfectely on Live editor.
Code:
```mermaid
sequenceDiagram
autonumber
Alice->>John: Hello John, how are you?
loop Healthcheck
John->>John: Fight against hypochondria
end
Note right of John: Rational thoughts!
John-->>Alice: Great!
John->>Bob: How about you?
Bob-->>John: Jolly good!
```
Someone can help me find my error on try write it on Github
Currently, I struggle on a similar problem.
With GitHub, do you mean GitHub pages?
Could you find a solution to it?
Personally, I have a setup with Jekyll. Here is my question on how to setup mermaid correctly for jekyll.
Interestingly, I just posted your mermaid into my jekyll page and the result is:
If I put it into <div> tags with class mermaid. Setup I used was this.
And if I use the jekyll spaceship-plugin, ist renders to:
I guess, that this what it should like. Am I right?
Therefore, so far, for me mermaid works based on the spaceship plugin, but not by "natively" referencing the mermaid JavaScript. I do not know if spaceship will work with GitHub pages, however, definitely within GitHub pages (which is based on Jekyll), you may also add plugins. See documentation for further details.

How to link to a file type search on GitHub?

On this pull request https://github.com/github/linguist/pull/3208 the Original Poster added some file search links for .nsi and .awk file types:
How did he do that? Is there some special syntax like #mention or user/repo#issue or he just did it the hard way:
[`.nsi` files](https://github.com/search?p=5&q=extension%3Ansi+if&ref=searchresults&type=Code&utf8=%E2%9C%93)
[`.awk` files](https://github.com/search?utf8=%E2%9C%93&q=extension%3Aawk+if&type=Code&ref=searchresults)
I'm not aware of any magic syntax for searches. Certainly nothing appears in the Mastering Markdown guide or the basic writing and formatting syntax page, though both describe user mentions, issue links, SHA links, etc.
I would speculate that the author of that comment performed a search in another tab, then copied the generated URL to their comment.

How to format a code block as is done by github's gist embed?

I have a Jekyll-powered blog, oriented towards programming for data analysis. I often embed github gists to display nicely formatted (highlighted) code blocks, and this works perfectly.
Now I'm wondering if it is possible to generate (locally on my machine) the same html code that's generated by the github gist embed, but for code files that are located on my computer instead of in github gist repo.
I guess my question could then be rephrased as:
- The html code that a 'github-gist embed' gives, how is it generated in the first place?
FYI: I'm not necessarily looking for a closed solution, any pointers on how to achieve this would also be very appreciated.

Markdown - code as link in GitHub readme

I wanted to create inline span of code that links to other page.
I want to use
`MongoCollection`
and
[MongoCollection](#http://php.net/manual/en/class.mongocollection.php)
together to make a link on a code element.
I tried
[`MongoCollection`](#http://php.net/manual/en/class.mongocollection.php)
and
`[MongoCollection](#http://php.net/manual/en/class.mongocollection.php)`
Both didn't work.
Is there any way to do that?
Could you explain a bit more about what you mean by inline span of code? This works in Github and links the MongoCollection link to the Mongo Collection php manual page.
[MongoCollection](http://php.net/manual/en/class.mongocollection.php)
Is that what you are looking for?