Browse Source

Script.js fix

pull/23/head
Jure Šorn 6 years ago
parent
commit
45160cc9ab
1 changed files with 11 additions and 3 deletions
  1. 14
      web/script.js

14
web/script.js

@ -5,14 +5,15 @@ $(document).ready(function() {
function parseMd() {
var GITHUB = 'https://raw.githubusercontent.com/gto76/python-cheatsheet/master/README.md';
jQuery.get(GITHUB, function(text) {
console.log(text)
text = removeMdToc(text);
console.log(text)
// console.log(text)
// text = removeMdToc(text);
// console.log(text)
var converter = new showdown.Converter();
html = converter.makeHtml(text);
aDiv = $('#main_container');
nodes = $.parseHTML(html);
aDiv.after(nodes);
removeOrigToc();
insertLinks();
d3.selectAll("code").each(function() { hljs.highlightBlock(this); });
addToc();
@ -36,6 +37,13 @@ function removeMdToc(text) {
return out.join('\n');
}
function removeOrigToc() {
headerContents = $('#contents')
contentsList = headerContents.next()
headerContents.remove()
contentsList.remove()
}
function insertLinks() {
$('h2').each(function() {
aId = $(this).attr('id');

Loading…
Cancel
Save