$(document).ready(function() {
parseMd();
});
function parseMd() {
var GITHUB =
"https://raw.githubusercontent.com/gto76/python-cheatsheet/master/README.md";
jQuery.get(GITHUB, function(text) {
var converter = new showdown.Converter();
html = converter.makeHtml(text);
aDiv = $("#main_container");
nodes = $.parseHTML(html);
aDiv.after(nodes);
removeOrigToc();
addToc();
insertLinks();
unindentBanner();
d3.selectAll("code").each(function() {
hljs.highlightBlock(this);
});
});
}
function removeOrigToc() {
headerContents = $("#contents");
contentsList = headerContents.next();
headerContents.remove();
contentsList.remove();
}
function insertLinks() {
$("h2").each(function() {
aId = $(this).attr("id");
text = $(this).text();
$(this).html('#' + text);
});
}
function unindentBanner() {
let montyImg = $("img").first();
montyImg.parent().addClass("banner");
let downloadPraragrapth = $("p").first();
downloadPraragrapth.addClass("banner");
}
function addToc() {
headerMain = $("#main");
nodes = $.parseHTML(TOC);
headerMain.before(nodes);
}
var TOC =
"
" +
'
ToC = {\n' +
' \'1. Collections\': [List, Dict, Set, Range, Enumerate, Namedtuple, Iterator, Generator],\n' +
' \'2. Types\': [Type, String, Regex, Format, Numbers, Combinatorics, Datetimeᴺᴱᵂ],\n' +
' \'3. Syntax\': [Arguments, Splat, Inline, Closure, Decorator, Class, Enum, Exceptions],\n' +
' \'4. System\': [Print, Input, Command_Line_Arguments, Open, Pathᴺᴱᵂ, Command_Execution],\n' +
' \'5. Data\': [CSV, JSON, Pickle, SQLite, Bytes, Struct, Array, MemoryView, Deque],\n' +
' \'6. Advanced\': [Threading, Introspection, Metaprograming, Operator, Eval, Coroutine],\n' +
' \'7. Libraries\': [Progress_Bar, Plot, Table, Curses, Loggingᴺᴱᵂ, Scraping, Web, Profile,\n' +
' NumPy, Image, Audio]\n' +
"}\n" +
"
\n";