Reputation: 419
I am using github-pages and jekyll to serve my own blog, where sometimes I put script files (python, MATLAB etc...) for the readers to download. Can I provide the readers with an option to preview the code file as text before they download it? I am imagining a scenario like when they click the hyperlink, instead of instantly downloading it, they are shown a page to view the code.
Upvotes: 1
Views: 1081
Reputation: 16866
You could host your code snippets as GitHub Gists, then link to the Gists on your blog so that users could view your code and optionally download it as well.
Upvotes: 1
Reputation: 1396
You can save the file as a .txt
file and then have 2 buttons or links: Download File
, Preview File
. You can either copy/paste into a new .txt
file or Save As and add the .txt
extension. Either way, you'll end up with the original file and then the .txt
version of it.
For example, if you have test.py
, then you can have the download link go to test.py
and the preview link go to test.py.txt
. The browser should render the .txt
file as plaintext.
Upvotes: 1