Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Feature: load code snippets from Github for sample codes #6

Closed
pkvenu opened this issue May 24, 2017 · 7 comments
Closed

Feature: load code snippets from Github for sample codes #6

pkvenu opened this issue May 24, 2017 · 7 comments

Comments

@pkvenu
Copy link

pkvenu commented May 24, 2017

In language tabs, I would like to load code snippets for each tab from Github rather than hard-coding it in markdown file. In markdown file, I would specify the Github Url for each language. This would help me save duplication content and single file as source of truth.

Is it something currently doable using Shins.

@MikeRalphson
Copy link
Contributor

Hi @pkvenu You can put anything into the right hand code snippets column by adding a section like:

<pre class="tab-shell">
<script src="https://gist.github.com/MikeRalphson/0c42c2778ea7a7a6fc0b5d59b4d7868e.js"></script>
</pre>

Where the class should be tab- plus the language code you want it to link to. I'm not sure how nice the formatting of GitHub code is going to show up, but the principle works.

@MikeRalphson
Copy link
Contributor

See also slatedocs/slate#776

@pkvenu
Copy link
Author

pkvenu commented May 24, 2017

@MikeRalphson - Can you tell me which file I would need to edit to add the section mentioned above. I tried looking at layouts/layout.ejs and javascript/app/_lang.js but not sure if that would be the right files to update. If you have some samples it would be really helpful.

Thanks,

@MikeRalphson
Copy link
Contributor

I'm away from my computer at the moment, but you can put the snippet above directly in your .md file.

@pkvenu
Copy link
Author

pkvenu commented May 24, 2017

I tried using the gist snippet and it shows the content but the layout is messed up and when we change tabs the content does not change.

<pre class="tab-shell">
<script src="https://gist.github.com/MikeRalphson/0c42c2778ea7a7a6fc0b5d59b4d7868e.js"></script>
</pre>

Ideally, What I would like to use is raw data from Gist/Github. When I try with a Gist raw data url the content is empty.

<pre class="tab-shell">
<script src="https://gist.githubusercontent.com/pkvenu/fe8c25b453f4c28c61d9/raw/9f2122f6edc2d724e5489cd27d36ee2e7a56a476/install.sh"></script>
</pre>

@MikeRalphson
Copy link
Contributor

I think what you need is some kind of markdown pre-processor. I rewrote markdown-pp from Python to Node.js as markdown-pp-js.

It has a function to include from URLs, so you should be able to do:

```js
!INCLUDEURL https://gist.githubusercontent.com/pkvenu/fe8c25b453f4c28c61d9/raw/9f2122f6edc2d724e5489cd27d36ee2e7a56a476/install.sh
``` 

@MikeRalphson
Copy link
Contributor

Closing due to inactivity, but please feel free to re-open.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants