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.

24 lines
618 B

5 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. });
  15. }
  16. function insertLinks() {
  17. $('h2').each(function() {
  18. aId = $(this).attr('id')
  19. $(this).append('<a href="#'+aId+'" name="'+aId+'">#</a>')
  20. })
  21. }