Skip to content

When copy and convert html to markdown, how to include latex in markdown? #57

@Norlandz

Description

@Norlandz

For example

Given a website with html:

<div>
  Define the Function: Let
  <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mrow>
      <mi>f</mi>
      <mo stretchy="false">(</mo>
      <mi>x</mi>
      <mo stretchy="false">)</mo>
      <mo>=</mo>
      <msup>
        <mi>x</mi>
        <mn>2</mn>
      </msup>
    </mrow>
  </math>
  , which has a <strong>derivative</strong>
  <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mrow>
      <msup>
        <mi>f</mi>
        <mo rspace="0em" lspace="0em" mathvariant="normal"></mo>
      </msup>
      <mo stretchy="false">(</mo>
      <mi>x</mi>
      <mo stretchy="false">)</mo>
      <mo>=</mo>
      <mn>2</mn>
      <mi>x</mi>
    </mrow>
  </math>
  .
</div>

When I copy & convert the html to markdown.

I want to include latex in markdown:

Define the function: Let $$ f(x) = x^2 $$, which has a **derivative** $$ f'(x) = 2x $$.

For clarification in case people dont know how latex works in html:

It is common to use latex in markdown. (eg: in RStudio, Ipynb, etc)
You can try to use https://upmath.me/ as online demo to see how it parses the latex in markdown.

The html I provided uses MathML for rendering formulas (latex),
so the whole point is to: Convert MathML code to Latex code.
Which is something very common, there should be many lib able to do this.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions