emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Way to mark contents of an Org special block as verbatim?


From: Kaushal Modi
Subject: Re: Way to mark contents of an Org special block as verbatim?
Date: Sat, 8 Jan 2022 23:03:42 -0500

On Sat, Jan 8, 2022 at 10:01 PM Berry, Charles <ccberry@health.ucsd.edu> wrote:
>
>
> A simple one here:
>
> #+begin_src emacs-lisp
>   ;; minimal backend with latex parent
>   (org-export-define-derived-backend 'newlatex 'latex
>     :translate-alist
>     '((special-block . org-newlatex-special-block)))
>
>   ;; special block transcoder
>   (defun org-newlatex-special-block (special-block contents info)
>     "Newlatex special block transcoder."
>     (let
>          ((type (org-element-property :type special-block)))
>       (if (equal type "newlatex")
>           (format "{{<FOO>}}\n%s{{<//FOO>}}\n" contents)

I am already doing something like this, but at this point in the code,
the `contents' already is the modified content i.e. Org entities
replaced and _{..} converted to <sub>, etc.

Note that ox-hugo exporter is extended from ox-md, which is extended
from ox-html.

My problem statement is that the contents I am receiving is already
modified and I don't get to access the original/raw/verbatim content.
Thanking the original example in this thread:

#+begin_katex
E = -J \sum_{i=1}^N s_i s_{i+1}
#+end_katex

- \sum will have converted to &sum;
- _{i=1} will have converted to <sub>i=1</sub> by the time I receive
the contents in ox-hugo's org-hugo-special-block.

[ May be I am doing something wrong in my exporter? ]

Or may be it's due to the fact that my eventual base exporter is ox-html?

>         ;; not `newlatex` so default to latex transcoder
>         (org-export-with-backend 'latex special-block contents info))))
> #+end_src
>
> Eval the above, then use this as an example by copying the following
> src block to an org buffer and entering
>
> M-; (org-export-to-buffer 'newlatex "*Org NEW LATEX Export*" nil nil nil t) 
> RET
>
> #+begin_src org
>
>   ,#+begin_newlatex
>   This is the new content
>   ,#+end_newlatex
>
>
>   ,#+attr_latex: :caption \MyCaption{HeadingA}
>   ,#+BEGIN_proof
>          dot-dot-dot
>   ,#+END_proof
>
> #+end_src
>
> I get an *Org NEW LATEX Export* buffer like this:
>
> #+begin_example
> {{<FOO>}}
> This is the new content
> {{<//FOO>}}
>
>
> \begin{proof}
> dot-dot-dot
> \MyCaption{HeadingA}
> \end{proof}
>
> #+end_example



reply via email to

[Prev in Thread] Current Thread [Next in Thread]