Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MathML support #303

Open
severny-polus opened this issue Feb 22, 2024 · 5 comments
Open

MathML support #303

severny-polus opened this issue Feb 22, 2024 · 5 comments

Comments

@severny-polus
Copy link

It would be helpful if you add MathML support instead of MathJax. It is supported by almost all modern browsers and does not require JavaScript at all.

@kensanata
Copy link
Contributor

Looking at the block.go file, it seems that using <math>…</math> is already supported?

@kjk
Copy link
Contributor

kjk commented Jul 30, 2024

I don't know those details off the top of my head.

Write a test and see what happens. You can start with https://tools.arslexis.io/goplayground/#txO7hJ-ibeU

Looking at this issue, I don't know what support MathML means.

I need to see the markdown, the expected html output and what we output. And also a link to https://babelmark.github.io/ with the same markdown.

Then we can discuss if this is the right behavior and how to fix if it's not the right behavior.

@kensanata
Copy link
Contributor

kensanata commented Jul 30, 2024

I added the following test to my block_test.go file, based on the spec:

// Inside MATH, so the other elements are passed through.
func TestMath(t *testing.T) {
	input := `# Some expression

<math><mtext>2 * x</mtext></math>
`
	p := NewWithExtensions(CommonExtensions)
	doc := p.Parse([]byte(input))
	var buf bytes.Buffer
	ast.Print(&buf, doc)
	got := buf.String()
	exp := "Heading\n  Text 'Some expression'\nHTMLBlock '<math><mtext>2 * x</mtext></math>'\n"
	if got != exp {
		t.Errorf("\nInput   [%#v]\nExpected[%#v]\nGot     [%#v]\n",
			input, exp, got)
	}
}

(This test, like the others, could be written data driven – right now it follows the examples in block_table_test.go…)

Perhaps the key is that people want to remove the MathJax option. An example like the following could be added to the documentation somewhere (this is from my own project):

	extensions := (parser.CommonExtensions | parser.AutoHeadingIDs | parser.Attributes) & ^parser.MathJax
	parser := parser.NewWithExtensions(extensions)

This assumes that I understand @severny-polus's issue correctly.

@kjk
Copy link
Contributor

kjk commented Jul 30, 2024

I might be wrong but I suppose what he means is: generate MathML syntax from MathJax syntax in markdown. But I'm just guessing, the request is vague.

@kensanata
Copy link
Contributor

Oof, a LaTeX to MathML converter? That's going to be super tough, I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants