I’m creating a blog using GitHub pages and using jekyll+kramdown.
I have a layout called base.html which has all headers, footers, meta, and everything except main body content.
I’m using this layout in the _post (markdown file)
filepath: _posts/2018-10-10-my-first-blog-post.md
---
layout: base
title: My first coding post
---
some description
<div id="mycode"></div>
Here I need to put a code snippet. this code will be fetched from GitHub raw content URL
for e.g https://raw.githubusercontent.com/MagicStack/httptools/master/setup.py
the content type of this url’s response is plain/text. so I’ll get this from javascript/jquery and put inside the div above-mentioned element. something like below -
jQuery.get('https://raw.githubusercontent.com/MagicStack/httptools/master/setup.py', function(data) {
var text = '```\n' + data + '\n```'; // adding 3 backtick to perform code formatting in markdown?
$('#mycode').html(text);
});
This is placed in the same markdown file just below the <div id=“mycode” /div> line.
but unfortunately, this is not working. I’m getting as a whole text inside the HTML including even backticks.
So to summarise my problem -
Get a raw code data in plain/text format from a URL and put in markdown with highlighting.
I’d be happy to clarify further if this is still not clear.
PS: I don’t want to use any third party url which changes the content type of raw gitusercontent eg rawgit, etc.