Skip to content

Math is not rendered in HTML #73

Open
@alexpearce

Description

Given the contents of foo.md:

The expression $$x = y$$ is boring.

When I run this command:

$ markup-toHTML foo.md

I get this output:

<p>The expression  is boring.</p>

The math has been removed.

I expect to get this:

<p>The expression $$x = y$$ is boring.</p>

Or perhaps this:

<p>The expression <math>x = y</math> is boring.</p>

(Preferably the former — keeping $$ — so that I can then pass the output to something like KaTeX.)


I get the same behaviour when using the API:

const { State } = require("markup-it");
const markdown = require("markup-it/lib/markdown");
const html = require("markup-it/lib/html");

const text = "The expression $$x = y$$ is boring.";

const mdState = State.create(markdown);
const document = mdState.deserializeToDocument(text);
const htmlState = State.create(html);
// console prints "<p>The expression  is boring.</p>"
console.log(htmlState.serializeDocument(document));

I've tried following through the logic of the conversion, but I haven't found anything obvious. My only clue is that the math element is represented as a node with isVoid: true. It might be that void nodes aren't converted to HTML, but I haven't found the line that would drop such nodes.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions