Libbum / oration

A Rocket/Elm self hosted commenting system for static sites
MIT License
22 stars 5 forks source link

Move to custom markdown implementation #71

Closed Libbum closed 6 years ago

Libbum commented 6 years ago

Looks like implementing a custom markdown parser is going to be the best bet to close #5, #1, and #58.

This is a wip to do just that. For now I've forked Evan's markdown package and merged the latest markdown-it package in, a la liamcurry's open PR (from 1.5 years ago) and used elm-install to pull that in as a package. Perhaps later on I may even bind it directly, as it looks like a) there's not going to be much movement to merge this upstream and b) I'd prefer not to require non-standard packages.

Edit: case in point, the tests are going to fail here unless I also install elm-install on travis.

Libbum commented 6 years ago

Alignment issue: Possibly related

Libbum commented 6 years ago

Direct x^2 using katex.render:

<span class="katex">
    <span class="katex-mathml">
        <math>
            <semantics>
                <mrow>
                    <msup>
                        <mi>x</mi>
                        <mn>2</mn>
                    </msup>
                </mrow>
                <annotation encoding="application/x-tex">x^2</annotation>
            </semantics>
        </math>
    </span>
    <span aria-hidden="true" class="katex-html">
        <span class="strut" style="height: 0.814108em;"></span>
        <span class="strut bottom" style="height: 0.814108em; vertical-align: 0em;"></span>
        <span class="base">
            <span class="mord">
                <span class="mord mathit">x</span>
                <span class="msupsub">
                    <span class="vlist-t">
                        <span class="vlist-r">
                            <span class="vlist" style="height: 0.814108em;">
                                <span class="" style="top: -3.063em; margin-right: 0.05em;">
                                    <span class="pstrut" style="height: 2.7em;"></span>
                                    <span class="sizing reset-size6 size3 mtight">
                                        <span class="mord mathrm mtight">2</span>
                                    </span>
                                </span>
                            </span>
                        </span>
                    </span>
                </span>
            </span>
        </span>
    </span>
</span>

Compared with elm rendered version:

<span class="katex">
    <span class="katex-mathml">
        <math>
            <semantics>
                <mrow>
                    <msup>
                        <mi>x</mi>
                        <mn>2</mn>
                    </msup>
                </mrow>
                <annotation encoding="application/x-tex">x^2</annotation>
            </semantics>
        </math>
    </span>
    <span class="katex-html" aria-hidden="true">
        <span class="strut" style="height:0.8141079999999999em;"></span>
        <span class="strut bottom" style="height:0.8141079999999999em;vertical-align:0em;"></span>
        <span class="base textstyle uncramped">
            <span class="mord">
                <span class="mord mathit">x</span>
                <span class="vlist">
                    <span style="top:-0.363em;margin-right:0.05em;">
                        <span class="fontsize-ensurer reset-size5 size5">
                            <span style="font-size:0em;"></span>
                        </span>
                        <span class="reset-textstyle scriptstyle uncramped">
                            <span class="mord mathrm">2</span>
                        </span>
                    </span>
                    <span class="baseline-fix">
                        <span class="fontsize-ensurer reset-size5 size5">
                            <span style="font-size:0em;"></span>
                        </span>

                    </span>
                </span>
            </span>
        </span>
    </span>
</span>

Where the font-size:0em spans as well as the empty looking row has a <200b> sitting in it

Libbum commented 6 years ago

The problem was the katex version that markdown-it-katex is using: 0.6.0. I need to be using the correct css to match that. Will submit a PR to update the version.

Edit: seems there are four open PRs to bump the version. I've put a watch on the repo.