MathJax

I want to use MathJAX in my posts to include better looking formulas. I included mathjax with and I’m using browser-sync to keep my scroll position locked for longer articles

    <script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"></script>

to include it into my html. Then

  \`x = (-b +- sqrt(b^2-4ac))/(2a) .\`

to get

A shell script to move my written summary over to my blog

Is not needed anymore thanks to auto scroll I know write all my summaries directly in my blog repository and live-view it on the website instead of Marked 2. This works because I now scroll automatically to my last position on a reload. With MDL this didn’t work, because there was a bug (also on Github). But Thanks to this snippet:

// FIX scroll bug (live-serve usually scrolls back but MDL has its own layout stuff which makes things complicated)
//...
this.blocked = false;

this.resetScrollState = function(){
            var mainScrollArea = document.getElementsByClassName('mdl-layout__content')[0];
            setTimeout(function () {
                if (window.location.href == localStorage.getItem('lastUrl')) {
                    mainScrollArea.scrollTop = localStorage.getItem('scrollTop');
                } else {
                    localStorage.setItem('lastUrl', window.location.href);
                    localStorage.setItem('scrollTop', 0);
                }
            }, 100);


            mainScrollArea.addEventListener('scroll', function () {
                if (!that.blocked) {
                    localStorage.setItem('scrollTop', this.scrollTop);
                    that.blocked = true;
                    setTimeout(function () {
                        that.blocked = false;
                    }, 200);
                }
            });
        };

window.onload = resetScrollState;

it doesn’t happen anymore and I can always keep going where I left off when i press ⌘ + s

Regex for copy / replacing in markdown documents

changing images sources

\(([0-9]*\.png)\)

replace e.g. with 

(\/images\/2016-02-02-social-computational-media-summary\/$1)

make all questions headlines

//selector for sublime regex filter
\n([0-9]{1,2}\.)
//replace
\n#### $1
//replace multimarkdown subscript with html subscript
~([a-z0-9]*)~
//replace
<sub>$1</sub>

parse markdown and make it usable for Ankidroid

This is not applicable anymore. Instead I use Javascript to parse the DOM and generate a CSV. Details in the custom.js file in this repository

assuming we have markdown written with headline level 4 or 5 as questions and answers afterwards, this regex can select and group our texts so we can convert it to a csv:

#{4,5}(.*)([^#]*)