From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id oE4WBY6JkF6ecAAA0tVLHw (envelope-from ) for ; Fri, 10 Apr 2020 14:58:22 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id qJ3FHI+JkF5pdgAA1q6Kng (envelope-from ) for ; Fri, 10 Apr 2020 14:58:23 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 5D9DD940446 for ; Fri, 10 Apr 2020 14:58:21 +0000 (UTC) Received: from localhost ([::1]:35548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jMv6q-0001Le-AP for larch@yhetil.org; Fri, 10 Apr 2020 10:58:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55016) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jMv5p-0000qC-Rt for emacs-orgmode@gnu.org; Fri, 10 Apr 2020 10:57:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jMv5o-0007v1-Ep for emacs-orgmode@gnu.org; Fri, 10 Apr 2020 10:57:17 -0400 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]:33359) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jMv5o-0007us-A2 for emacs-orgmode@gnu.org; Fri, 10 Apr 2020 10:57:16 -0400 Received: by mail-qt1-x829.google.com with SMTP id x2so1639577qtr.0 for ; Fri, 10 Apr 2020 07:57:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=iOM3liYLuIBOC0XLR1tLPRRadHIeoqrCx7u8gMSGu0A=; b=f4FqkQsGoq8N6vSIipcziDapt3RnAVhohDojFcBtWEtrk2BYjARRVdkM17PN4qvVIc HIEVLhSjv/pa/XJnUeUQw6vgMbj3BVFCKT3hB5kBzByCnHazsomMyNBQ3BvVlCKgT+tZ RB40Xmn99cBojxkQTvUG+kFA1m90dRvsRPehN5p6gtJCvmgo56koO/0vu1+bJHjG7SI3 A1gtZP0dufG8wo5cCmsM1ELUSCPPGFgVX9BqlQuqOIDWuZ5X5qEq1Xb4zuEtX5edkvvy c4KSwRDsVr4aqA2q/mUYJRDB/YUI+Ql2Wvklj7yrrpMNEVNG603ihLUm1oG0LzZOuuzH Jbxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=iOM3liYLuIBOC0XLR1tLPRRadHIeoqrCx7u8gMSGu0A=; b=kWuMeL40lFxEV8PrOuSdWOn6fBWb4EHLbAzCdvIwR+2B3PF69P/NtB5wr62qrX+K0b oL1kp2j+Jof1kiPd/zqx2Il/KJn6JFdbgFmTdDgZGVGh2DfuQXTxRdgRwb/Lpp67N8iL 5138fNnK+088BiMI7MGWewaoTzP4vAGKS+jOSS1t/Ol4+y8P5mDs/qFvyTFf8kVDh8xu vgL5Jj4l2xJiirsXwPziY+y1Kp6yszSJ0Rpo2aLxKZk9MfK8drtSJiAuxfoL9cv1WZF6 LC+kO5DIL+qi9syrXrIpDtJ5BukvvwM/QgsPuORl/TLlpFO0jz9MI9WefIXErZQ/nIAj FuIA== X-Gm-Message-State: AGi0PuZqhRhcGMBomk0V6MIyZOkRNpyDXC2rOYkiIXLM52s8rOVoxOpS Qjx3iHAkMo0sex4m2CcsS7qltFeMgO6myYksXBkn5Aml X-Google-Smtp-Source: APiQypKe8beoBjGTVe/NYlkLBXbnRKsFV3zTD+IXxvUS6xprE57d0hfIrrbyO1ZO+troshRZs32p0jQaLHXHI3yICjI= X-Received: by 2002:ac8:70d6:: with SMTP id g22mr4660623qtp.27.1586530635007; Fri, 10 Apr 2020 07:57:15 -0700 (PDT) MIME-Version: 1.0 From: Salomon Turgman Date: Fri, 10 Apr 2020 10:56:51 -0400 Message-ID: Subject: How to add new type of block to a derived back-end? To: emacs-orgmode@gnu.org Content-Type: multipart/alternative; boundary="000000000000eccaef05a2f0f27c" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::829 X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=default; t=1586530701; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=iOM3liYLuIBOC0XLR1tLPRRadHIeoqrCx7u8gMSGu0A=; b=cToOWycyqECKJfsUOrzrVb2Tqn41WsMDQotFq+anN4xkvFhud9ggCuaukaPOrZmm3rwC3V 5N1pHNT6AgsEPgEYHg0eqTreX8Rep4VKIDw1Gq3N7cOjKfCtskvpytVBMGSvVPLGKMZ/xE EERtewNE9yu41TdSxZY8t79QoWxqyg8= ARC-Seal: i=1; s=default; d=yhetil.org; t=1586530701; a=rsa-sha256; cv=none; b=UokX+GLJzKIsLp32REHn6WaX7OHxVLNNYM0WR0aJne1L1VMfOMv/frYDuaYZzaWyahDKDf ki8GrTty8/GYAzqkR7lQlYzMjB9Q4W7BGKjMbD2jM8ZfHlhS6gtuE9YUKyMsrBU//I5YhE AxNKuiuR61cEzBBP8UWT+ZGHUxeh73Q= ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=f4FqkQsG; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Scanner: scn0 X-Spam-Score: -0.71 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=f4FqkQsG; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Scan-Result: default: False [-0.71 / 13.00]; GENERIC_REPUTATION(0.00)[-0.58009427937114]; R_SPF_ALLOW(-0.20)[+ip4:209.51.188.0/24:c]; FREEMAIL_FROM(0.00)[gmail.com]; TO_DN_NONE(0.00)[]; ARC_SIGNED(0.00)[i=1]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.30), country: US(-0.01), ip: 209.51.188.17(-0.58)]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; MX_GOOD(-0.50)[cached: eggs.gnu.org]; MAILLIST(-0.20)[mailman]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:22989, ipnet:209.51.188.0/24, country:US]; SUBJECT_ENDS_QUESTION(1.00)[]; TAGGED_FROM(0.00)[larch=yhetil.org]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; RCVD_COUNT_FIVE(0.00)[6]; FROM_HAS_DN(0.00)[]; FROM_NEQ_ENVFROM(0.00)[sturgman@gmail.com,emacs-orgmode-bounces@gnu.org]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[emacs-orgmode@gnu.org]; HAS_LIST_UNSUB(-0.01)[]; RCPT_COUNT_ONE(0.00)[1]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: CtfnkpOEUWi2 --000000000000eccaef05a2f0f27c Content-Type: text/plain; charset="UTF-8" Hello all, Thanks in advance for any hints you can provide for this. I am trying to create a derived back-end that handles a new type of block in org-mode. I am trying to derive using the html export backend as a parent. Currently I am solving my problem like this: #+CAPTION[Manual control]: Simulation 1: Manual control of the tank level. #+BEGIN_EXPORT html
Simulation 1: Manual control of the tank level.
#+END_EXPORT This has a few downsides: 1. I have to specify the caption twice since export translator does not handle captions. 2. I have to include substantial amounts of html. 3. I have keep track of references to simulations manually (simulation 1, simulation 2, etc) 4. I have to include the identifier `main1` or `Main1` in several locations in the snippet. I could solve some of this with an automated snippet insertion tool but I thought that maybe I can get the export back-end to do most of the work for me. So I am trying to derive as follows (in pseudo-elisp-code): (require 'ox) (require 'ox-html) (org-export-define-derived-backend 'textbook 'html :menu-entry '(?I "Export textbook section" ((?b "To buffer" org-html-export-as-html) (?I "To file" org-html-export-to-html) (?o "As HTML file and open" (lambda (a s v b) (if a (org-html-export-to-html t s v b) (org-open-file (org-html-export-to-html nil s v b))))))) :translate-alist '((simulation . org-textbook-simulation))) (defun org-textbook-simulation (element contents info) (let* ((simnum (extract simnum value)) (caption (org-export-get-caption element)) (divid (extrac divid value)) (modid (convert divid into modid)) ) (format "
Simulation %simnum%: %Caption%.
" simnum caption divid modid divid))) With the hope that I can do something like this in my .org file: #+CAPTION[Manual control]: Simulation 1: Manual control of the tank level. #+BEGIN_SIMULATION main1 Some other cool stuff here #+END_SIMULATION Am I on the right track here? Can someone point me to an example on how to: 1. Keep track of the number of simulations for referencing? 2. Extract the caption properly? The above is just my guess. 3. Extract the divid value (main1) 4. And finally, how to get org to recognize the new SIMULATION block so that it can apply `org-textbook-simulation`? Do I need to register this type of block somewhere? Or is the name of the first member of the :translate-alist translation pair have some special meaning? Thank you very much for any assistance and thank you for org-mode! -s- --000000000000eccaef05a2f0f27c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello all,

Thanks in advance for any hints you= can provide for this. I am trying to create a derived back-end that handle= s a new type of block in org-mode. I am trying to derive using the html exp= ort backend as a parent.

Currently I am solving my= problem like this:
#+CAPTION[Manu= al control]: Simulation 1: Manual control of the tank level.
#+BEGIN_EXP= ORT html
<div class=3D"caption">Simulation 1: Manual con= trol of the tank level.</div>
<div class=3D"simulation&quo= t;>
<div id=3D"main1">
<noscript>
Some other cool stuff here.
</noscript>
</div>
</d= iv>
<script>var app =3D Main1.init({node: document.getElementBy= Id("main1")});</script>
#+END_EXPORT

This has a= few downsides:
1. I have to specify the caption twice since expo= rt translator does not handle captions.
2. I have to include subs= tantial amounts of html.
3. I have keep track of references to si= mulations manually (simulation 1, simulation 2, etc)
4. I hav= e to include the identifier `main1` or `Main1` in several locations in the = snippet.

I could solve some of this with an automa= ted snippet insertion tool but I thought that maybe I can get the export ba= ck-end to do most of the work for me.

So I am tryi= ng to derive as follows (in pseudo-elisp-code):
(require 'ox)
(require 'ox-html)

(or= g-export-define-derived-backend 'textbook 'html
=C2=A0 :menu-ent= ry
=C2=A0 '(?I "Export textbook section"
=C2=A0 =C2=A0 = =C2=A0 =C2=A0((?b "To buffer" org-html-export-as-html)
=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (?I "To file" org-html-expor= t-to-html)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (?o "As HTML = file and open"
=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 (lambda (a s v b)
=C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (if a (org-html-export-to-html t s v b)
= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 (org-open-file (org-html-export-to-html nil s v b)))))))=C2=A0 :translate-alist '((simulation . org-textbook-simulation)))
(defun org-textbook-simulation (element contents info)
=C2=A0 (let*= ((simnum (extract simnum value))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 (caption (org-export-get-caption element))
=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (divid (extrac divid value))
=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (modid (convert divid into modid))=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 )
=C2=A0 =C2=A0 (fo= rmat "<div class=3D\"caption\">Simulation %simnum%: %C= aption%.</div>
=C2=A0 <div class=3D\"simulation\">=
=C2=A0 =C2=A0 <div id=3D\"%divid%\">
=C2=A0 =C2=A0 &= lt;/div>
=C2=A0 </div>
<script>var app =3D %modid%.ini= t({node: document.getElementById(\"%divid%\")});</script>&q= uot;
=C2=A0 =C2=A0simnum caption divid modid divid)))

With the hope that = I can do something like this in my .org file:

#+CAPTION[Manual control]: Simulation= 1: Manual control of the tank level.
#+BEGIN_SIMULATION main1
Some other cool= stuff here
#+END_SI= MULATION

Am I on the right track here?= Can someone point me to an example on how to:
1. Keep t= rack of the number of simulations for referencing?
= 2. Ex= tract the caption properly? The above is just my guess.
=
= 3. Extract the divid value (main1)
4. And finally, how t= o get org to recognize the new SIMULATION block so that it can apply `org-t= extbook-simulation`? Do I need to register this type of block somewhere? Or= is the name of the first member of the :translate-alist translation pair h= ave some special meaning?

Th= ank you very much for any assistance and thank you for org-mode!

-s-

--000000000000eccaef05a2f0f27c--