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

parser: latex support? #41

Open
v2gt opened this issue Jan 7, 2020 · 4 comments
Open

parser: latex support? #41

v2gt opened this issue Jan 7, 2020 · 4 comments

Comments

@v2gt
Copy link

v2gt commented Jan 7, 2020

希望:

  1. parser解析出latex公式: $a+b$, [a+b ]
  2. orga-rehype 生成的html直接就可以展示数学公式,比如用katex

输入org:

* test

  $a+b$


  \[a+b+\alpha\]

html
<div class="section"><h1>test</h1><p>$a+b$</p><p>\[a+b+\alpha\]</p></div>

会的,这个 parser 会尽量跟org-mode syntax 12保持一致。对于parser本身,我觉得最make sense 的实现是直接返回node:

{
type: “latex”,
name: “equation”,
value: “x=\sqrt{b}”
}
具体的render可以在org-mode to HTML 层用其他包来实现。这样其实就没有多少工作在parser这边。

@gitonthescene
Copy link

In #49 I suggest adding plugin support. With that, one of these might be helpful.

@LaloHao
Copy link

LaloHao commented Jun 5, 2021

@gitonthescene
Copy link

gitonthescene commented Jun 6, 2021

Here's a POC of using LaTeX

Live: https://blorg-latex.hao.systems/using-latex
Source: https://github.com/LaloHao/gatsby-theme-blorg-latex

@LaloHao Is this all done with the katex import? I.e. did this require zero changes to orgajs? I mean you didn’t have to render the latex to the AST at all right?

@LaloHao
Copy link

LaloHao commented Sep 11, 2021

Here's a POC of using LaTeX
Live: https://blorg-latex.hao.systems/using-latex
Source: https://github.com/LaloHao/gatsby-theme-blorg-latex

@LaloHao Is this all done with the katex import? I.e. did this require zero changes to orgajs? I’m you didn’t have to render the latex to the AST at all right?

Yes, you don't need to change orgajs internals, you can do it on your own project

There are 2 commits on my example repository:

  1. First one is the original source code
  2. Second one is the changes to you add to use katex

How to:

  1. I ran npm install --save katex rehype-katex rehype-math rehype-parse for the dependencies

  2. I added the css file to gatsby-browser.js

require('katex/dist/katex.min.css');
  1. Create a new component post with latex processing

  2. Create org-mode posts

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