4 ms·
So how does this work exactly? It looks like you wrote a script.js file, which calls showdown.js library (converting markdown to html). A uglified version call
by Kagerjay 8y ago
So how does this work exactly?
It looks like you wrote a script.js file, which calls showdown.js library (converting markdown to html). A uglified version called `md-page` is made pulling both resources
Basically, the script does following
1) wait for page to load
2) add css-styles via javascript
3) shove all the markdown in a variable "markdown", passing it as one giant string
4) Add settings for showdown.js
5) Rewrite entire markdown on page to HTML via showdown.js
6) Append to body and render
I could fork it and add breakpoints / run debugger but this is what I got from looking at source code
- oscargeorge 8y agoyep. you're 100% on the money. no wizardry here. Couple of extra features like ability to hash link, and external url open in new window. but that it
- Kagerjay 8y agohttps://github.com/oscarmorrison/md-page/blob/master/script.js https://github.com/oscarmorrison/md-page/blob/master/script.... Line 43 to 48, I am not entirely sure what that hashlink does. What is the setTimeout function for? Could you expand on that?
- oscargeorge 8y agoIt's to make linking to headers work. Eg oscarmorridon.com/md-page#code As the element doesn't exist at time of first load this is a work around to focus on id once content is rendered in html
- oscargeorge 8y ago* https://oscarmorrison.com/md-page/#code https://oscarmorrison.com/md-page/#code