reddit / emacs

Org-mode expands org-special-block-extras incorrectly

NoisyFrequency · 2022-06-03 10:35
I've been using [`org-special-block-extras`](https://github.com/alhassy/org-special-block-extras) to insert special blocks in `org-mode` which I then export to PDF through LaTeX, things such as margin notes or colored blocks. It used to work until recently (couple days ago) but now the special blocks are expanded incorrectly and it errors out. Minimal example, #+title: This is a title #+author: ME * Introduction Next, writing in the margin. #+begin_margin note this is a margin note #+end_margin * END This used to expand to a `\marginpar` such as shown into the docs : (o-defblock margin (marker nil :display 'full :face '(:foreground "grey" :weight bold :underline "orange" :overline "orange")) (color "gray!80" counter "footnote" width "\\paperwidth - \\textwidth - \\oddsidemargin - 1in - 3ex") ;; Width: https://tex.stackexchange.com/a/101861/69371 :please-inline__no-extra-newlines__k-thx-bye! "Produce an HTML tooltip or a LaTeX margin note. The ‘margin’ block is intended for “one-off” (mostly optional) remarks. For notes that you want to use repeatedly, in multiple articles or in multiple locations in the same article, consider using ‘documentation’ to declare them and ‘doc’ to invoke them. For LaTeX, place ‘#+resize:’ to have the remainder of a block be resized, for now 1.3 the margin width ---requires \\usepackage{adjustbox}. ---------------------------------------------------------------------- WIDTH, COUNTER, and COLOR are LaTeX specfic. When no label, marker, is used for a marginal note, we rely on a COUNTER, such as ‘footnote’ (default) or ‘sidenote.’ Since HTML has no margin per se, we use “∘” as default marker: Users hover over it to read the marginal note. Marginal notes have their labels, markers, in black and the notes themselves have COLOR being grey!80. In Emacs, margin links appear grey with an orange tinted boarder. Regarding LaTeX, since verbatim environments do not in general work well as arguments to other commands, such as ‘\\marginpar’, we save the contents of the special block in a ‘minipage’ within a LaTeX ‘box’; then we can unfold such a box in the margin. Hence, ‘src’ blocks can appear within ‘margin’ blocks (•̀ᴗ•́)و The WIDTH argument is the width of the margin; i.e., the width of the underlying minipage. One could use \\maxsizebox{.25\\textwidth}{\\textheight}{ ... } which only resizes the content if its natural size is larger than the given 〈width〉 or 〈height〉. We don't use this, since maxsizebox does not natively allow linebreaks (e.g., one would wrap contents in a tabular environment then use ‘\\\\’, two backslashes, to request a line break; but this crashes if one wants to also use verbatim environments.) In LaTeX, it may be useful to invoke ‘\\dotfill’." (-let [stepcounter (if marker "" (format "\\stepcounter{%s}" counter))] (pcase backend (`latex (setq marker (or marker (format "{\\the%s}" counter))) ;; "\\circ" (format "\\!\\!${}^{\\textnormal{%s}}$ \\newsavebox{\\OrgSpecialBlockExtrasMarginBox} \\begin{lrbox}{\\OrgSpecialBlockExtrasMarginBox} \\begin{minipage}{%s} \\raggedright \\iffalse Otherwise default alignment is fully justified. \\fi \\footnotesize \\setminted{fontsize=\\footnotesize, breaklines} \\iffalse HACK! \\fi \\color{%s} {\\color{black}${}^{\\textnormal{%s}}$}\n\\normalfont\n %s \\end{minipage} \\end{lrbox} \\marginpar{\\usebox{\\OrgSpecialBlockExtrasMarginBox}%s} \\hspace{-1.9ex} \\global\\let\\OrgSpecialBlockExtrasMarginBox\\relax" marker width color marker (if (s-contains? "#+resize:" contents) (s-concat (s-replace "#+resize:" "#+latex: \\maxsizebox{1.3\\textwidth}{\\textheight}{\\begin{tabular}{l}\n" (s-trim contents)) "\n\\end{tabular}}") (s-trim contents)) stepcounter)) (_ (setq marker (or marker "°")) (format "<abbr class=\"tooltip\" title=\"%s\">%s</abbr>&emsp13;" (o-html-export-preserving-whitespace contents) ; MA: FIXME: (org-export-string-as contents 'html :body-only-please) marker))))) But now, it simply expands to \begin{margin} this is a margin note \end{margin} Since there is no such thing as a margin environment, LaTeX compilation fails. Relevant information : - Emacs version : GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.34, cairo version 1.17.6) of 2022-06-03 - Org version : Org mode version 9.5.3 (release_9.5.3-6-gef41f3 @ /usr/local/share/emacs/29.0.50/lisp/org/) - org-special-block-extras version : 20220326.1432
NoisyFrequency · 2022-06-04 11:17
For anyone interested, I deleted my `eln-cache`, `package-quickstart.el` and `elpa` directories and reloaded everything, it works now for some reason.