louietan / anki-editor

Emacs minor mode for making Anki cards with Org
700 stars 87 forks source link

Whitespace surronding latex environments is not respected #7

Closed torfjelde closed 6 years ago

torfjelde commented 6 years ago
 is of the form

\begin{equation*}
  \hat{H} = \hat{H}_0 + \hat{H}'
\end{equation*}

where

becomes

is of the form [latex]\begin{equation*} \hat{H} = \hat{H}_0 + \hat{H}' \end{equation*} [/latex]where

Could do one of the following:

  1. Check for discrepancy between :end of previous element and :begin of latex element, and insert what's missing
  2. By default insert \n before and after a latex-environment, since it's not that usual to inline something which ought to be wrapped in "[latex]%s[/latex]"
louietan commented 6 years ago

Hi Could you try execute anki-editor-convert-region-to-html on the region of your example and paste the result here ? According to the syntax of Org-mode, empty lines separate paragraphs (so there's no need to do what you suggested here, but thank you any way, you make me find another problem which I'll talk later). I tried your example with that command, and it gave me the HTML as below

<p>
is of the form
</p>

<p>
[latex]\begin{equation*}
  \hat{H} = \hat{H}_0 + \hat{H}'
\end{equation*}
[/latex]
where</p>

which is what I expect. If your output is the same as mine, then it should be rendered as two paragraphs in Anki, not a single line. The only problem I can see here is the example should be converted to three paragraphs instead of two, which will be fixed in next version.

torfjelde commented 6 years ago

I get the same output as you now (both when submitting and converting)! Which is a bit weird, but alright. But yeah, it being converted to three paragraphs as you noted would be perfect, so thanks!

louietan commented 6 years ago

Not at all. Happy learning :-)