Closed torfjelde closed 6 years ago
Did some debugging and it seems like it's an issue with how org-element
extracts the contents after (org-element-parse-buffer)
is called in anki-editor--process-note-heading
. *Perturbation Theory*
is treated as a headline
for some reason.
I would like to know which version of Emacs and Org-mode you're using? I tried your example, it worked fine.
I don't know if there once was a bug in org-element
as you described, but how could it be rendered as blank if was treated as a headline ?
Since I can't reproduce your problem, could you paste and elaborate the snippet which you think buggy here?
I need more clues, so please
Back
headinganki-editor-export-heading-contents-to-html
Emacs 25.1 and org-20180115
.
Using anki-editor-export-heading-contents-to-html
(when point is at the Back
heading) it works fine:
<p>
<b>Perturbation Theory</b> provides a method for finding <i>approx.</i> energy eigenvalues and eigenstates for a system whose Hamiltonian is of the form
</p>
<p>
[latex]\begin{equation*}
\hat{H} = \hat{H}_0 + \hat{H}'
\end{equation*}
[/latex]
where [$]\hat{H}_0[/$] is the Hamiltonian of an <i>exactly</i> solvable system, for which we know the eigenvalues, [$]E_n^{(0)}[/$], and eigenstates, [$]\ket{n^{(0)}}[/$], and [$]\hat{H}'[/$] is <i>small, time-independent perturbation</i>.
</p>
But Back
is still empty if I submit to Anki.
I tried you example myself, Anki reported an error saying something like ! Undefined control sequence.<recently read> \ket
. I don't use latex very often, but \ket
seems to belong to the package physics
, so you may have to check if you have added \usepackage{physics}
to the latex preamble of your note type. (you can do this from menu bar "Tools -> Manage Note Types -> Options")
It's not that no; I'm already including \usepackage{physics}
and it works fine if I just don't start the paragraph with *Perturbation Theory*
.
As I noted in my earlier comments, it seems to "disappear" when you car
the results from (org-element-parse-buffer)
in anki-editor--process-note-heading. For some reason it's not included under the heading in this case, and ends up being dropped.
Oh well, I can reproduce this now. Yep, *Perturbation Theory*
seems to be interpreted as headline by org-element
, I'm still investigating.
Seems I have to enable Org major mode in the temp buffer to make org-element
functions correctly.
org-element
uses buffer-local variable outline-regexp
to test headline, the default value of which is "[*\^L]+"
, which matches any text that starts with stars, that's why bold being interpreted as headline.
When org
gets enabled, it overwrites this variable with org-outline-regexp
, whose value is "\\*+ "
that's stars followed by a space. Also the doc string of org-element-parse-buffer
says it assumes that current major mode is org-mode
, so we have to enable Org-mode before using org-element
.
971181d fixes this.
First of, this package is great! Before I've been using a small personal script which copies a region, wraps latex and maths, thus I could just paste into a card in Anki. What you've got going her, is waaay better. Thank you!
When attempting to submit this card, the
Back
is left blank.If I then add some random text in front of
*Perturbation Theory*
, e.g.abc *Perturbation Theory*
, it works.I'll be happy to help out if you need help!