From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id QEMnNwUasmF1MQEAgWs5BA (envelope-from ) for ; Thu, 09 Dec 2021 16:00:21 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id 8GQEMwUasmFGCQAAB5/wlQ (envelope-from ) for ; Thu, 09 Dec 2021 15:00:21 +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 73F40943F for ; Thu, 9 Dec 2021 16:00:21 +0100 (CET) Received: from localhost ([::1]:51792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mvKuC-0008PJ-2s for larch@yhetil.org; Thu, 09 Dec 2021 10:00:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mvKqd-0002W3-AB for emacs-orgmode@gnu.org; Thu, 09 Dec 2021 09:56:41 -0500 Received: from ciao.gmane.io ([116.202.254.214]:57366) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mvKqZ-0001TT-Sm for emacs-orgmode@gnu.org; Thu, 09 Dec 2021 09:56:37 -0500 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1mvKqX-0004bE-Dv for emacs-orgmode@gnu.org; Thu, 09 Dec 2021 15:56:33 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org From: Max Nikulin Subject: Re: Raw Org AST snippets for "impossible" markup Date: Thu, 9 Dec 2021 21:56:16 +0700 Message-ID: References: <4897bc60-b74f-ccfd-e13e-9b89a1194fdf@mailbox.org> <87fsrbp673.fsf@gmail.com> <1ef0e093-c165-2a5f-954d-6a33b64c8ee9@mailbox.org> <87r1avgnpi.fsf@localhost> <878rx2bzhw.fsf@nicolasgoaziou.fr> <9525e029-a590-3f48-df64-ffb9176075d9@mailbox.org> <87k0gh68ke.fsf@posteo.net> <8735n2hehj.fsf@posteo.net> <87lf0u8dnf.fsf@posteo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 X-Mozilla-News-Host: news://news.gmane.io In-Reply-To: <87lf0u8dnf.fsf@posteo.net> Content-Language: en-US Received-SPF: pass client-ip=116.202.254.214; envelope-from=geo-emacs-orgmode@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FORGED_MUA_MOZILLA=2.309, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NICE_REPLY_A=-2.803, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 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" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1639062021; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=duGSKas+8t8Yn1MEdxmC3IYsIopc75YYPIIfNBu7eVQ=; b=qTomRO/AT/lHb1VkDcraGNxN4EaMz2VWl7rn/nXLu15824n9OjBpGdIYSQe64eRD0/JluQ gUWUCajXNBG5ppyuzFCeL4YRbbA0G9y8lcYEOK9+hCirzUbL3/FV3e1b60b/bI6sc9GoyP 0/Gsi9QuAc10z08o3K/n+Z3F0Aq0RFqMrqom35+RgyFhO0vYsxz2SVwoJTOvjVVK2kt+bF yDIpSIGn+P5qoBDvN5vKyY40lldbIQvXMPYKuf+SKsuxVK90U83uXPImg/+FrSMh2b3s67 6dKCI+aRPVnb820wu6tXd1KQoOmGUHSXl7kaBIGzwRqBzo7J+TTegyKNmG6rgQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1639062021; a=rsa-sha256; cv=none; b=YExlfnGevifgFjqfAhfpUV0tbPf8OS3RygPwfZf+qOXvwdLplNqMuCc2fiaJ58Ap2C/OYG oXg4jzsihVdE/Ntvahyz4mqSxf5bo0WjD1GkRSdeamy+HaePtQWH/Mj6VKrdEriGNXB2X9 GaEDyqPw7cc89LoqOhilYsZEvpuaKCMjoAbG08yXP8amOz4IHfAy8pO3TP2upjRai3Vug5 HYzMBF83Pu6B7KNCOull0SCMDmJXfBIXDN5f31uKtLnsI2ehtHpWbaPAiOwgRl/6kXSQTN w1nH7C9nMemJDRdJLRQTOq6AIIlr14k26koDgSC9AtuwZVnj3bC9VQNASjtUnQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.36 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 73F40943F X-Spam-Score: -2.36 X-Migadu-Scanner: scn1.migadu.com X-TUID: VhbXWGgYd1Zy On 09/12/2021 14:01, Juan Manuel MacĂ­as wrote: > John Kitchin writes: > >> Have you seen >> https://github.com/tj64/org-dp? It seems to do a lot with creating and >> manipulating org elements. It might either be handy or lead to some >> inspiration. > > Interesting package. Thanks for sharing. Either I missed something or its purpose is completely different. It maps Org markup to Org markup. I am experimenting with fragments that should allow to get something that is really tricky or even impossible with established syntax, so it has to run immediately before exporters. > It gave me an idea, also borrowing part of Maxim's code, but evaluating > in this case the path. To continue playing with links... The goal is > to obtain a link with this structure `[[quote-lang:lang][quote]]': > > #+BEGIN_SRC emacs-lisp :results silent > (org-link-set-parameters > "quote-lang" > :display 'full > :export (lambda (path desc bck) > (let* ((bck org-export-current-backend) > (attr (list (format > ":environment foreigndisplayquote :options {%s}" > path))) > (info (org-export-get-environment > bck nil nil))) > (org-no-properties > (org-export-data-with-backend > `(quote-block (:attr_latex ,attr) > ,desc) > bck info))))) > #+END_SRC Looking into your code I have realized that it should be implemented using filter, not through :export property of links. Maybe without working proof of concept with link exporters, this session of monkey-typing would not be successful. #+begin_src elisp :results silent (defun orgia-element-replace (current new destructive?) (if (eq current new) current (let* ((lst? (and (listp new) (not (symbolp (car new))))) (new-lst (if lst? (if destructive? (nconc new) (reverse new)) (list new)))) (dolist (element new-lst) (org-element-insert-before element current))) (org-element-extract-element current) new)) (defun orgia--transform-link (data) (if (not (string-equal "orgia" (org-element-property :type data))) data (let* ((path (org-element-property :path data))) (if (not (eq ?\( (aref path 0))) (or path (org-element-contents data)) (read path))))) (defun orgia-parse-tree-filter (data _backend info) (org-element-map data 'link (lambda (data) (orgia-element-replace data (orgia--transform-link data) t)) info nil nil t) data) #+end_src #+begin_src elisp :results silent (add-to-list 'org-export-filter-parse-tree-functions #'orgia-parse-tree-filter) (org-link-set-parameters "orgia") #+end_src #+begin_src elisp (org-export-string-as "An word" 'html t) #+end_src #+RESULTS: :

: An interword