You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
806 B

6 years ago
6 years ago
6 years ago
  1. $(document).ready(function() {
  2. parseMd()
  3. });
  4. function parseMd() {
  5. var GITHUB = 'https://raw.githubusercontent.com/gto76/python-cheatsheet/master/README.md'
  6. jQuery.get(GITHUB, function(text) {
  7. var converter = new showdown.Converter()
  8. html = converter.makeHtml(text)
  9. aDiv = $('#main_container')
  10. nodes = $.parseHTML(html)
  11. aDiv.after(nodes);
  12. insertLinks()
  13. d3.selectAll("code").each(function() { hljs.highlightBlock(this); });
  14. // addToc()
  15. });
  16. }
  17. function insertLinks() {
  18. $('h2').each(function() {
  19. aId = $(this).attr('id')
  20. $(this).append('<a href="#'+aId+'" name="'+aId+'">#</a>')
  21. })
  22. }
  23. function addToc() {
  24. headerMain = $('#main')
  25. nodes = $.parseHTML(TOC)
  26. headerMain.before(nodes)
  27. }
  28. var TOC = '<h2 id="toc">Contents<a href="#toc" name="toc">#</a></h2>'