This is the same what @tobyp provided me with here and here.
We will have to accept @DanielFlaum’s assessment that at present it is not possible to have a properly working header counter in CSS for Preview.
@tobyp provided a halfway solution: a count for the H1 headers only, and that works.
Here is the code:
/** initialize css counter */
body {
counter-reset: head-num-1;
}
/* put counter result into H1 headings */
.markdown-source-view .cm-formatting-header-1::after , h1::before {
counter-increment: head-num-1;
content: counter(head-num-1) ". ";
}