* Re: How to convert an HTML export bloc to a normal Org Babel output ?
@ 2023-05-25 8:46 copropriete27ruemoret
2023-05-25 10:50 ` Ihor Radchenko
0 siblings, 1 reply; 4+ messages in thread
From: copropriete27ruemoret @ 2023-05-25 8:46 UTC (permalink / raw)
To: yantar92, emacs-orgmode@gnu.org
[-- Attachment #1: Type: text/plain, Size: 540 bytes --]
[ For some reason, an answer posted yesterday seems to have been lost. Rewriting/reposting... ]
Nice answer ! I suppose that this is more a misdesign than a bug (limited goals of Dyalog,that emacs-jupyter cannot alleviate).
Your suggestion worked. But now, I have to pass to my `:post` function various arguments that a "normal" source block handler should have done. Is there a way for the `post` function to access the (say..) `:results`, `:file`, etc... arguments of the source block ?
Sincerely,
--
Emmanuel Charpentier
[-- Attachment #2: Type: text/html, Size: 619 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to convert an HTML export bloc to a normal Org Babel output ?
2023-05-25 8:46 How to convert an HTML export bloc to a normal Org Babel output ? copropriete27ruemoret
@ 2023-05-25 10:50 ` Ihor Radchenko
0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2023-05-25 10:50 UTC (permalink / raw)
To: copropriete27ruemoret; +Cc: emacs-orgmode@gnu.org
copropriete27ruemoret@gmail.com writes:
> [ For some reason, an answer posted yesterday seems to have been lost. Rewriting/reposting... ]
You did not CC Org mailing list.
> Nice answer ! I suppose that this is more a misdesign than a bug (limited goals of Dyalog,that emacs-jupyter cannot alleviate).
>
> Your suggestion worked. But now, I have to pass to my `:post` function various arguments that a "normal" source block handler should have done. Is there a way for the `post` function to access the (say..) `:results`, `:file`, etc... arguments of the source block ?
`org-babel-current-src-block-location' holds the location of the current
src block being executed. You can use it to determine header arguments
of your src block.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 4+ messages in thread
* How to convert an HTML export bloc to a normal Org Babel output ?
@ 2023-05-24 10:03 Emmanuel Charpentier
2023-05-24 12:16 ` Ihor Radchenko
0 siblings, 1 reply; 4+ messages in thread
From: Emmanuel Charpentier @ 2023-05-24 10:03 UTC (permalink / raw)
To: emacs-orgmode@gnu.org
[-- 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}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to convert an HTML export bloc to a normal Org Babel output ?
2023-05-24 10:03 Emmanuel Charpentier
@ 2023-05-24 12:16 ` Ihor Radchenko
0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2023-05-24 12:16 UTC (permalink / raw)
To: Emmanuel Charpentier; +Cc: emacs-orgmode@gnu.org
Emmanuel Charpentier <emm.charpentier@free.fr> writes:
> #+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.
Check if jupyter-apl has default :wrap header arg. If not, it directly
adds #+begin/end_export lines and the best you can do is (1) report it
as a bug; (2) manually filter out begin/end_export in your :post function.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-05-25 10:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-25 8:46 How to convert an HTML export bloc to a normal Org Babel output ? copropriete27ruemoret
2023-05-25 10:50 ` Ihor Radchenko
-- strict thread matches above, loose matches on Subject: below --
2023-05-24 10:03 Emmanuel Charpentier
2023-05-24 12:16 ` Ihor Radchenko
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.