From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id XVa3HraokF6iOgAA0tVLHw (envelope-from ) for ; Fri, 10 Apr 2020 17:11:18 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id CEbYBriokF7qOAAAbx9fmQ (envelope-from ) for ; Fri, 10 Apr 2020 17:11:20 +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 C794E942D08 for ; Fri, 10 Apr 2020 17:11:17 +0000 (UTC) Received: from localhost ([::1]:37222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jMxBU-0005Qq-M7 for larch@yhetil.org; Fri, 10 Apr 2020 13:11:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44765) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jMxAv-0005QA-LF for emacs-orgmode@gnu.org; Fri, 10 Apr 2020 13:10:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jMxAt-0002I3-U1 for emacs-orgmode@gnu.org; Fri, 10 Apr 2020 13:10:41 -0400 Received: from mx0a-00395d01.pphosted.com ([148.163.133.170]:51152) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jMxAt-0002Gx-A5 for emacs-orgmode@gnu.org; Fri, 10 Apr 2020 13:10:39 -0400 Received: from pps.filterd (m0173168.ppops.net [127.0.0.1]) by mx0a-00395d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03AGxcTE024214; Fri, 10 Apr 2020 10:10:36 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucsd.edu; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=campus; bh=BVZvwmGado0qk2yRBzmVLUBW3VE44UPkmhOzDK2TN1U=; b=iT48lFFaofceNPNBaivG6hGIMp12nynMu1YEwrmEiEp1OJYD99yBYvIyc3Vvs79+Kowq i1mvUO55gdpZwEEgmY4rygs339NjgfXhDWHascOG4wQs5FeN8BCmwDnypSqKxHQcESNc 2ZUwVXt/UWu2DGR3HYPoQB3IE4am7tCVmX3D9zLlqwEnkt7DdCHG/aTwb2ikiPlHf3F7 Tu3a78iVFqnZRZelptUQoCqYKMEELLCv/8Oxsh7sAODhQNfIBgUlV5FMNLsvjSmDRWqm ozc6H5VahNvw616fo114ahUWZLQ9BZeETiA5solZpQAQRTxbga/f9gcbhOseljN7h8Vp Og== Received: from secdlpezp04.ucsd.edu ([40.112.251.180]) by mx0a-00395d01.pphosted.com with ESMTP id 30aabc98cd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Apr 2020 10:10:36 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XN2q6ywJI0MSP1PhZRl0gpQJDe/dwBAGgRZSbt7O0/rpo7RgEU7UGp/IDoI0pl2fiYzCwYiS1XNQllMvkfP8tIpSUJz/Zsy0KE9s1XAlcmnKdvjLKb70GZf28kleCsYmvCW/2c5UIZWvxw9tGbtm5p/na+J4D2rnVQZp96OHWEwIdC9w2GI4PfA4htsx431jUFntgxCXP5/XUcpBpba1n3ZRMEYNuEtR3Mot+jBv73yTC/Q5k5xzYANM0X92kSKbwDOjaPtNJI4gxyV7Am+5g6SOz07GZO7zZqeR87slBi5zMIDNFxkqJ64bQgMi3Uj5cQy6oH0NrkU1c7yCsUn/fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BVZvwmGado0qk2yRBzmVLUBW3VE44UPkmhOzDK2TN1U=; b=IDTycx0j8fPE0aLArNHEUV8LrxTIjtpteszDOHaWXo7Vsj8aPkWFHG6aUEM6SvS2vzsinNRZFQOhwKlUU1XAZTXiQJLRFrnuF49Sr7z2ezJGQhtPsEVmh+S4mDu67pSNJn8I+dMvegZMyz/xb+0nY+yTHYFx3Nc6q6N/5o2yM4Glio1F1zifsEAn5tJUDJwm8/nmEajklf5ZaDXtHC4S73uwADzwAJroLvR6QhAtNyb1g3EV416n3lwlKnAAnNEi/4batcrGuBCoWuyVIfuJ8iZpIIuLBwWDKUIQa5fXTUv6byWYtFAY6e8YkyaBE0FjNW+sY/XZFLvDxBL99ph7+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 132.239.0.26) smtp.rcpttodomain=gnu.org smtp.mailfrom=health.ucsd.edu; dmarc=temperror action=none header.from=health.ucsd.edu; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucsdcloud.onmicrosoft.com; s=selector2-ucsdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BVZvwmGado0qk2yRBzmVLUBW3VE44UPkmhOzDK2TN1U=; b=fdeA+++lyloUvLvjg+xNEzr58tpLyj1+CqLbRFmeECCY/DG6IAJcJFqiehLFwKEZXabN86vwKc1VrhEyyWTC2d+mJ56PzmUY5luf76ZFqIn9enDMfsKdNXxUi1eQBd/XUzSACKm+zdw1Yn0/IvAFsGPts8TeOhjODT8uTw3lFWg= Received-SPF: TempError (protection.outlook.com: error in processing during lookup of health.ucsd.edu: DNS Timeout) To: Salomon Turgman Subject: Re: How to add new type of block to a derived back-end? Thread-Topic: How to add new type of block to a derived back-end? Thread-Index: AQHWD1rksHXmdYaiq0mBrFkrpffJEA== Date: Fri, 10 Apr 2020 17:10:12 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.7.165.110] Content-Type: text/plain; charset="us-ascii" Content-ID: <7BABC0F97766F644885B02D43C7829F1@AD.UCSD.EDU> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:132.239.0.26; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:newmail.ucsd.edu; PTR:xmail-a1.ucsd.edu; CAT:NONE; SFTY:; SFS:(10009020)(346002)(396003)(39860400002)(136003)(376002)(46966005)(356005)(8676002)(47076004)(246002)(75432002)(336012)(63350400001)(63370400001)(4326008)(6916009)(82740400003)(7696005)(36756003)(186003)(53546011)(5660300002)(70586007)(316002)(8936002)(33656002)(786003)(9686003)(26005)(86362001)(478600001)(2906002)(70206006)(7636003); DIR:OUT; SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8ee27a77-5300-4e31-bad0-08d7dd7213c5 X-MS-TrafficTypeDiagnostic: SN6PR04MB4926: X-Microsoft-Antispam-PRVS: x-campus_o365: o365_983452 X-MS-Oob-TLC-OOBClassifiers: OLM:2582; X-Forefront-PRVS: 0369E8196C X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MOtHjb8fIAQVxGMssA3DZXmPu4rpEs8zbSdthPkQ3jJMoQ+DRzJKNvP24g1l4ki8dCzWxhwK2aIQAGA9vtuVZXInIivBtqjcef7SiZPh+5YN9NttVEewGN3xVVJHlmiGFeb+Hat+v8oW2FXxrHwMXW4mdKj0K40SVuc54tSvqjPRFgjMd2MSbsJsgzKP/A+3m25LBJn4kkIxSAHwXhoQV553+uWvU0Awvpwoz+gQT9djWPYAcZJndzAiX/HwGarlt2xnnIxRkAsbPZ2ufwjq/4kAf4si72orM06xQBPmKazGb685QUUGpK1HlRcrhrHhOgUQH/eNiKfqu18CpI1A6CRqpkCsl0gme/36/Wqn9/KCJ8RG3uzZFvfJObYi6zf2XKeBrrD95uSCnjftzP/opKtPxgABJKQqHdkNnVwiOBgLDFJKv85604wcehXcPaQjBdeqhXscTyC9UgTF48kEQcAl7hwP/YPOQnE+50woMDcIzKXDO8wnrG20ClVJ7U2hpJxbzVTwg2PiF8jngB3opw== X-OriginatorOrg: ucsd.edu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2020 17:10:32.2770 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8ee27a77-5300-4e31-bad0-08d7dd7213c5 X-MS-Exchange-CrossTenant-Id: 8a198873-4fec-4e76-8182-ca479edbbd60 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=8a198873-4fec-4e76-8182-ca479edbbd60; Ip=[132.239.0.26]; Helo=[newmail.ucsd.edu] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR04MB4926 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-10_06:2020-04-09, 2020-04-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1011 mlxlogscore=999 priorityscore=1501 mlxscore=0 malwarescore=0 bulkscore=0 suspectscore=0 spamscore=0 adultscore=0 phishscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004100139 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 148.163.133.170 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: , Cc: org mode Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" Reply-to: "Berry, Charles" From: "Berry, Charles" via "General discussions about Org-mode." ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=default; t=1586538678; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=BVZvwmGado0qk2yRBzmVLUBW3VE44UPkmhOzDK2TN1U=; b=JurYtJZP2XJhdRWcz0dTgbdHTJXnN+B9L0wo3hqSlySUhHHrp5Kw2xqHLpKQx13emuP0dp z4T8nK/v56OV0HU+kxRhlOL51dM6jhnJ0wF8VySsoYWJS7RWOr6Xu0QEAFg2KMcowKHJez S5nOGPwzqbHjGg8fAudtrMnHEWkNUKw= ARC-Seal: i=2; s=default; d=yhetil.org; t=1586538678; a=rsa-sha256; cv=fail; b=lG5ys7kNlbd1JARuEBZQJ3Bcb9kJLY+FazC4b6NWOe3TiR1lma5WwXyk3NV2chXeRltwd8 B/+cjsJYXK+Y9D73If+c0xQbXRLShOaPcHEb+mkwGDsERXKqd4Ci5J99rYDkv9K0APgCu/ ZKiROQEEyGCD+2fZNF+HGl7OC7htpuA= ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=ucsd.edu header.s=campus header.b=iT48lFFa; dkim=fail (rsa verify failed) header.d=ucsdcloud.onmicrosoft.com header.s=selector2-ucsdcloud-onmicrosoft-com header.b=fdeA+++l; arc=reject (signature check failed: fail, {[1] = sig:microsoft.com:reject}); 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: 2.99 Authentication-Results: aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=ucsd.edu header.s=campus header.b=iT48lFFa; dkim=fail (rsa verify failed) header.d=ucsdcloud.onmicrosoft.com header.s=selector2-ucsdcloud-onmicrosoft-com header.b=fdeA+++l; dmarc=none; 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 [2.99 / 13.00]; HAS_REPLYTO(0.00)[ccberry@health.ucsd.edu]; GENERIC_REPUTATION(0.00)[-0.58009054643735]; HAS_XOIP(0.00)[]; R_DKIM_REJECT(1.00)[ucsd.edu:s=campus,ucsdcloud.onmicrosoft.com:s=selector2-ucsdcloud-onmicrosoft-com]; R_SPF_ALLOW(-0.20)[+ip4:209.51.188.0/24:c]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.30), country: US(-0.01), ip: 209.51.188.17(-0.58)]; ARC_SIGNED(0.00)[i=2]; ARC_REJECT(2.00)[signature check failed: fail, {[1] = sig:microsoft.com:reject}]; TO_DN_ALL(0.00)[]; MX_GOOD(-0.50)[cached: eggs.gnu.org]; RCPT_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[ucsd.edu:-,ucsdcloud.onmicrosoft.com:-]; MAILLIST(-0.20)[mailman]; FREEMAIL_TO(0.00)[gmail.com]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; 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]; FROM_NEQ_ENVFROM(0.00)[emacs-orgmode@gnu.org,emacs-orgmode-bounces@gnu.org]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[text/plain]; REPLYTO_DOM_NEQ_FROM_DOM(0.00)[]; DMARC_NA(0.00)[gnu.org]; HAS_LIST_UNSUB(-0.01)[]; RCVD_COUNT_SEVEN(0.00)[7]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: V/pAZqd6d6BP Salomon, see inline comments below.=20 HTH,=20 Chuck > On Apr 10, 2020, at 7:56 AM, Salomon Turgman wrote: >=20 > Hello all, >=20 > 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 a= m trying to derive using the html export backend as a parent. >=20 > 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 >=20 > This has a few downsides: > 1. I have to specify the caption twice since export translator does not h= andle 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 locatio= ns in the snippet. >=20 > 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 fo= r me. >=20 > So I am trying to derive as follows (in pseudo-elisp-code): > (require 'ox) > (require 'ox-html) >=20 > (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))) >From the `org-export-define-backend' docstring: "TRANSCODERS is an alist between object or element types and functions handling them." But `simulation' is not such a type. So, this will not work. >=20 > (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))) >=20 > With the hope that I can do something like this in my .org file: >=20 > #+CAPTION[Manual control]: Simulation 1: Manual control of the tank level= . > #+BEGIN_SIMULATION main1 > Some other cool stuff here > #+END_SIMULATION I think an easier approach is to write a babel src-block that formats the i= nputs you need and creates a value that is your desired output.=20 Use `:var' header arguments to define the inputs. =20 Use `:wrap html' to prevent the exporter from changing the output. Subsequent calls can use the `#+CALL' idiom. You can use any scripting language that suits you - elisp, python, shell, R= , ... --- for this purpose.=20 If you are skilled in emacs-lisp you might write an `eval' macro instead of= a src block. >=20 > Am I on the right track here? Can someone point me to an example on how t= o: > 1. Keep track of the number of simulations for referencing? Using the babel approach, you would need a `:session' with a persistent var= iable that would hold the count. You would need to initialize it in your do= cument so that subsequent exports will start counting at zero. > 2. Extract the caption properly? The above is just my guess. IIRC, the info channel is not populated when babel runs, so you will need t= o parse the src-block and extract the `:caption' element. I think you can u= se a `:var cap=3D(find-caption)' idiom, where `find-caption' is a function = you write using `org-element-context' as a starting point. Or if the only need you have for the caption is within that src block just = use `:var cap=3D"". > 3. Extract the divid value (main1) :var divid=3D"main1" > 4. And finally, how to get org to recognize the new SIMULATION block so t= hat 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-a= list translation pair have some special meaning? Don't go in that direction. Use babel or write an eval macro. [snip]=