From: Emmanuel Charpentier <emm.charpentier@free.fr>
To: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: How to convert an HTML export bloc to a normal Org Babel output ?
Date: Wed, 24 May 2023 12:03:01 +0200 [thread overview]
Message-ID: <d945548f0f4593212e20eb0945d9034b5b7795e1.camel@free.fr> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 2458 bytes --]
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 #1.2: Type: text/html, Size: 2565 bytes --]
[-- Attachment #2: DyalogAttempt.html --]
[-- Type: application/xhtml+xml, Size: 9709 bytes --]
[-- Attachment #3: DyalogAttempt.odt --]
[-- Type: application/vnd.oasis.opendocument.text, Size: 10874 bytes --]
[-- Attachment #4: DyalogAttempt.org --]
[-- Type: text/org, Size: 2065 bytes --]
# 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 #5: DyalogAttempt.pdf --]
[-- Type: application/pdf, Size: 15638 bytes --]
[-- Attachment #6: DyalogAttempt.tex --]
[-- Type: text/x-tex, Size: 2027 bytes --]
% 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}
next reply other threads:[~2023-05-24 10:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-24 10:03 Emmanuel Charpentier [this message]
2023-05-24 12:16 ` How to convert an HTML export bloc to a normal Org Babel output ? Ihor Radchenko
-- strict thread matches above, loose matches on Subject: below --
2023-05-25 8:46 copropriete27ruemoret
2023-05-25 10:50 ` Ihor Radchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d945548f0f4593212e20eb0945d9034b5b7795e1.camel@free.fr \
--to=emm.charpentier@free.fr \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).