Dear list,

I stumbled on the conversion of an HTML Babel export block to a "normal" Babel 
output. What follows is the *verbatim* transcript of an org file explaining and 
demonstrating the problem :

```
# Attempt to use emacs-jupyter to insert Dyalog APL org-src blocks. 
#+options: author:nil toc:nil
#+latex_compiler: lualatex
#+latex_header: \usepackage{minted}
#+latex_header: \usepackage{fontspec}
#+latex_header: \setmonofont{Unifont}

#+property: header-args:jupyter-apl :kernel dyalog-kernel :session pa

I want to use APL `src` blocks in an Org document. This can be done by using
[[https://www.dyalog.com/][Dyalog APL]] interpreter though
[[https://github.com/emacs-jupyter/jupyter][jupyter-emacs]] and the Dyalog
[[https://github.com/Dyalog/dyalog-jupyter-kernel][jupyter kernel]].

This apparently works :


#+begin_src jupyter-apl :exports both :results replace
  ⍳7
#+end_src

#+RESULTS:
#+begin_export html
<pre class="language-APL">1 2 3 4 5 6 7
</pre>
#+end_export

But, no matter what I try to use as parameters, Dyalog's kernel returns an HTML 
block, which exports to HTML
successfully (of course) but /not/ to LaTeX nor `.odt`/`docx` or even `Unicode 
text`. A glimpse at the
kernel's source code (partially in APL, beware !) suggests that's a /feature/ 
of this kernel, which returns
either HTML or graphics (which I didn't (yet) attempt to use).

I then attempted to work around this (mis)feature by converting the HTML block 
to text, using this
Stackoverflow 
[[https://stackoverflow.com/questions/64796235/html-to-text-conversion-in-emacs][suggestion]]
 :

#+name: html2text
#+begin_src emacs-lisp :var data="<pre></pre>" :exports code :results silent
  (with-temp-buffer
    (insert data)
    (shr-render-region (point-min) (point-max))
    (buffer-substring-no-properties (point-min) (point-max)))
#+end_src

#+RESULTS: html2text

The conversion works fine :

#+begin_src jupyter-apl :exports both :results raw :post html2text(data=*this*)
  ⍳7
#+end_src

#+RESULTS:
#+begin_export html 

1 2 3 4 5 6 7
#+end_export 

but what /enrages/ me is that the (correct) result is still wrapped in an HTML 
block ; again, I have been
unable to obtain a "normal" output.

Can someone suggest a way to transform an HTML export block to a normal output ?

```

Source file and various exports enclosed (HTML is correct, the other ones not).

The question still holds...

Attachment: DyalogAttempt.html
Description: application/xhtml

Attachment: DyalogAttempt.odt
Description: application/vnd.oasis.opendocument.text

# Attempt to use emacs-jupyter to insert Dyalog APL org-src blocks. 
#+options: author:nil toc:nil
#+latex_compiler: lualatex
#+latex_header: \usepackage{minted}
#+latex_header: \usepackage{fontspec}
#+latex_header: \setmonofont{Unifont}

#+property: header-args:jupyter-apl :kernel dyalog-kernel :session pa

I want to use APL `src` blocks in an Org document. This can be done by using [[https://www.dyalog.com/][Dyalog APL]] interpreter though [[https://github.com/emacs-jupyter/jupyter][jupyter-emacs]] and the Dyalog [[https://github.com/Dyalog/dyalog-jupyter-kernel][jupyter kernel]].

This apparently works :


#+begin_src jupyter-apl :exports both :results replace
  ⍳7
#+end_src

#+RESULTS:
#+begin_export html
<pre class="language-APL">1 2 3 4 5 6 7
</pre>
#+end_export

But, no matter what I try to use as parameters, Dyalog's kernel returns an HTML block, which exports to HTML successfully (of course) but /not/ to LaTeX nor `.odt`/`docx` or even `Unicode text`. A glimpse at the kernel's source code (partially in APL, beware !) suggests that's a /feature/ of this kernel, which returns either HTML or graphics (which I didn't (yet) attempt to use).

I then attempted to work around this (mis)feature by converting the HTML block to text, using this Stackoverflow [[https://stackoverflow.com/questions/64796235/html-to-text-conversion-in-emacs][suggestion]] :

#+name: html2text
#+begin_src emacs-lisp :var data="<pre></pre>" :exports code :results silent
  (with-temp-buffer
    (insert data)
    (shr-render-region (point-min) (point-max))
    (buffer-substring-no-properties (point-min) (point-max)))
#+end_src

#+RESULTS: html2text

The conversion works fine :

#+begin_src jupyter-apl :exports both :results raw :post html2text(data=*this*)
  ⍳7
#+end_src

#+RESULTS:
#+begin_export html 

1 2 3 4 5 6 7
#+end_export 

but what /enrages/ me is that the (correct) result is still wrapped in an HTML block ; again, I have been unable to obtain a "normal" output.

Can someone suggest a way to transform an HTML export block to a normal output ?

Attachment: DyalogAttempt.pdf
Description: Adobe PDF document

% Created 2023-05-24 mer. 11:50
% Intended LaTeX compiler: lualatex
\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage{minted}
\usepackage{fontspec}
\setmonofont{Unifont}
\date{\today}
\title{}
\hypersetup{
 pdfauthor={Emmanuel Charpentier},
 pdftitle={},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 28.2 (Org mode 9.6.6)}, 
 pdflang={English}}
\begin{document}

I want to use APL `src` blocks in an Org document. This can be done by using \href{https://www.dyalog.com/}{Dyalog APL} interpreter though \href{https://github.com/emacs-jupyter/jupyter}{jupyter-emacs} and the Dyalog \href{https://github.com/Dyalog/dyalog-jupyter-kernel}{jupyter kernel}.

This apparently works :


\begin{minted}[]{apl}
⍳7
\end{minted}

But, no matter what I try to use as parameters, Dyalog's kernel returns an HTML block, which exports to HTML successfully (of course) but \emph{not} to \LaTeX{} nor `.odt`/`docx` or even `Unicode text`. A glimpse at the kernel's source code (partially in APL, beware !) suggests that's a \emph{feature} of this kernel, which returns either HTML or graphics (which I didn't (yet) attempt to use).

I then attempted to work around this (mis)feature by converting the HTML block to text, using this Stackoverflow \href{https://stackoverflow.com/questions/64796235/html-to-text-conversion-in-emacs}{suggestion} :

\begin{minted}[]{common-lisp}
(with-temp-buffer
  (insert data)
  (shr-render-region (point-min) (point-max))
  (buffer-substring-no-properties (point-min) (point-max)))
\end{minted}

The conversion works fine :

\begin{minted}[]{apl}
⍳7
\end{minted}

but what \emph{enrages} me is that the (correct) result is still wrapped in an HTML block ; again, I have been unable to obtain a "normal" output.

Can someone suggest a way to transform an HTML export block to a normal output ?
\end{document}

Reply via email to