From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id uES9ExvvrWGPIgAAgWs5BA (envelope-from ) for ; Mon, 06 Dec 2021 12:08:11 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id WCN1DxvvrWEEVAAA1q6Kng (envelope-from ) for ; Mon, 06 Dec 2021 11:08:11 +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 EE17429C9D for ; Mon, 6 Dec 2021 12:08:10 +0100 (CET) Received: from localhost ([::1]:33254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muBqr-000668-30 for larch@yhetil.org; Mon, 06 Dec 2021 06:08:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muBgv-0005E5-HT for emacs-orgmode@gnu.org; Mon, 06 Dec 2021 05:57:53 -0500 Received: from ciao.gmane.io ([116.202.254.214]:50886) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muBgs-00016g-M3 for emacs-orgmode@gnu.org; Mon, 06 Dec 2021 05:57:53 -0500 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1muBgF-0003ug-AS for emacs-orgmode@gnu.org; Mon, 06 Dec 2021 11:57:11 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org From: Max Nikulin Subject: Raw Org AST snippets for "impossible" markup Date: Mon, 6 Dec 2021 17:57:04 +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> 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 In-Reply-To: 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: 28 X-Spam_score: 2.8 X-Spam_bar: ++ X-Spam_report: (2.8 / 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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, 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 X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1638788891; 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=nsQSbf65DVm6eh5fmM7txbKPws3hF3kK793bIm5TQec=; b=TxfHA+sZ7OHXspk1a9XENmY1VxSvoj+VmxmkgJ7Gzm5J95v4GWPwP8e63Cy64rh0ics+Rs NdswsIfOJbgZatGrUDdtitgVPB2AyhkGNUq59XAbZINVxewBbmUVGCBD3SK7qSJ/lCjtmP iLiEnR+DD3C0SOsuSrDUsHUUSFKdejjWrvfTkeJXTiylg42MswI5JtUZlLtBcmSbmyGmmC jUDa/7es+QJO3rEPG4XT2Xp3HuQrYFh3RQjDXtVWfzTXjlWROuRrj7QKXQG+n/x7VRrc3p YsZG41ElCN3emYFVG7g8QX/FVRz72qncfKs7WTDgZCGbEYX3kO5K13v9KrKP7A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1638788891; a=rsa-sha256; cv=none; b=dG22oXDMzvDOg+az7ksLlFfKuAQfNV7Us4haNRcR2PgPekYb9qr3cu/2qdzgVUIjVFQTjW /TAWgAH48X1eZkEvyAzfKghxt38nQBHcy5/CNrBNf2Mn6AKG/OfwXvy8qJyDZrkrVn0Ave t2m1+HGDqNGAU1/dlEWvrVkPMieds6MUdAxemMch10jo6yZzr3Zw1hCrUIn6Aan7xlgihf L7pxaSGyCN3M85WRNs904LesAllodqDyI0+cu5s+/2dU7mrTtkee9lNjSGfhnfS5Mtb95P kYEXZrMPl9SzbVfRSTcHATY4BNlZjGZDJmjSYZ0Lc7otSLhr2SAAJ2mO8HRZ7g== 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.34 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: EE17429C9D X-Spam-Score: -2.34 X-Migadu-Scanner: scn0.migadu.com X-TUID: TE/cqSCpFS4j On 05/12/2021 01:37, John Kitchin wrote: > Along these lines (and combining the s-exp suggestion from Max) , you > can achieve something like this with links. > > #+BEGIN_SRC emacs-lisp :results silent > (defun italic (s) >   (pcase backend ;; lexical >     ('latex (format "{\\textit{%s}}" s)) >     ('html (format "%s" s)) >     (_ s))) > > (defun @@-export (path desc backend) >   (eval `(concat ,@(read path)))) > > (org-link-set-parameters >  "@@" >  :export #'@@-export) > #+END_SRC John, thank you for the reminding me of Juan Manuel's idea that everything missed in Org may be polyfilled (ab)using links. It is enough for proof of concept, special markers may be introduced later. After some time spent exercising in monkey-typing, I have got some code that illustrates my idea. So the goal is to mitigate demand to extend current syntax. While simple cases should be easy, special cases should not be impossible. - Raw AST snippets should be processed without ~eval~ to give other tools such as =pandoc= a chance to support the feature. If you desperately need ~eval~ then you can use source blocks. - The idea is to use existing backends by passing structures similar to ones generated by ~org-element~ parser. - I would prefer to avoid "@@" for link prefix since such sequences are already a part of Org syntax. In the following example export snippet is preliminary terminated by such link: #+begin_src elisp :results pp (org-element-parse-secondary-string "@@latex:[[@@:(italics \"i\")]]@@" (org-element-restriction 'paragraph)) #+end_src #+RESULTS: : ((export-snippet : (:back-end "latex" :value "[[" :begin 1 :end 13 :post-blank 0 :parent #0)) : #(":(italics \"i\")]]@@" 0 18 : (:parent #0))) Let's take some link prefix that makes it clear that the proposal is a draft and a sane variant will be chosen later when agreement concerning details of such feature is achieved. Till that moment it is named "orgia". #+begin_src elisp :results silent (defun orgia-export (path desc backend) (if (not (eq ?\( (aref path 0))) path (let ((tree (read path)) (info (org-export-get-environment backend nil nil))) (org-no-properties (org-export-data-with-backend tree backend info))))) (org-link-set-parameters "orgia" :export #'orgia-export) #+end_src Either [[orgia:("inter" (bold () "word"))]] or links may be used. Certainly plain text may be outside: #+begin_src elisp (org-export-string-as "A word" 'html t) #+end_src #+RESULTS: :

: A interword

- Error handling is required. - Elements (blocks) should be considered as an error in object (inline) context. - Passed tree should be preprocessed to glue strings split to avoid interpreting them as terminating outer construct or link itself (=]]= =][= should be ="]" "]"= ="]" "["= inside bracket links). It is especially important for property values. - For convenience =parse= element may be added to parse a string accordingly to Org markup. - There should be a similar element (block-level markup structure). - Symbols and structures used by ~org-element~ becomes a part of public API, but they are already are since they are used by export backends. - ~org-cite~ is likely will be a problem.