简体   繁体   中英

how to embed a github git README file on a website

I am making a website for someone and they want to be able to have that site fetch the github readme markdown file at a certain URL and display it on the website, so that instead of having to write the readme in two places, it just pulls from github. Is that possible? How do I do it? I saw this:

https://github.com/coreyti/showdown

which turns markdown into html, but I'm still not how I would fetch the readme URL and convert it into an object that showdown could parse.

Any ideas would be greatly appreciated.

GitHub has an option to show file source, Raw button in top right corner. Raw link for your example is: https://raw.github.com/coreyti/showdown/master/README.md

Assuming that README file is formatted in Markdown already, you could just fetch source and format it on your side, libraries most probably already exist for your language.

UPDATE

I wouldn't actually download file from GitHub every time the page on your site is requested. GitHub may be down, connection may be slow -- and this will affect visitors of your site. Instead, you may want to have a cron job running on the server that would download a file from GitHub, say, every five minutes, and cache it locally. Then, every time you need to display the file, you'll read a local copy and don't depend on GitHub server being accessible. As a drawback, you will have a certain synchronization delay (5 minutes in my example).

You can use StackEdit . It allows you to publish your markdown document on Github and on others locations at the same time in Markdown or HTML format. For instance, you could publish the HTML on a public Google Drive or Dropbox location.

NOTE: I'm the developer of StackEdit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM