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 uIMOJN4DYV8EEQAA0tVLHw (envelope-from ) for ; Tue, 15 Sep 2020 18:11:42 +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 wDJiHt4DYV9lZAAAbx9fmQ (envelope-from ) for ; Tue, 15 Sep 2020 18:11:42 +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 E82369400D3 for ; Tue, 15 Sep 2020 18:11:41 +0000 (UTC) Received: from localhost ([::1]:60440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kIFQa-00051l-Tv for larch@yhetil.org; Tue, 15 Sep 2020 14:11:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58208) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIFP8-0004Mx-67 for emacs-orgmode@gnu.org; Tue, 15 Sep 2020 14:10:10 -0400 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]:35712) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kIFP2-00029U-E8 for emacs-orgmode@gnu.org; Tue, 15 Sep 2020 14:10:09 -0400 Received: by mail-ej1-x636.google.com with SMTP id u21so6437758eja.2 for ; Tue, 15 Sep 2020 11:10:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zzamboni-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pd79JhgbS0d+/u/pKrZ82gJrMwvpJEC3qYMFCWDKiIw=; b=ruqawdYbIAB7KDWS9+IISxzxCWSJMewxys4MzEoklVaqTxM4gRMAhzP76sq+wGVcF9 JvX1DM+r3OrLqUz0NkLlo5Gdx8ntUwEkWsc4tr8oIcWehXLGOEra6KrXNl0IuHe5WfgT zjla9dl/EFoSBiJY9R3Ch/WTUtcBq8UuvR/0nPLzFeLMlBBExPGsppycmAV0xGCHuuBj tU6CKgDYN2nyUh9nntgS6OvZtUfhXaOTcFo5pT0a/yckh3Mnr6EHxNaTuf27VR/ZKkxN trKrV9Avxp39apPkUSC1Tef7X2MmTujW1ljHWdj/tXBJI4P4C9hrX1mu4qV/H+2vWjjD ZRBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pd79JhgbS0d+/u/pKrZ82gJrMwvpJEC3qYMFCWDKiIw=; b=SeAnv6kyYaD1bLikIWa4uzTVwXQG5aF06BnMfCMHn6KksrDvBabcLU6DLD4/gmcO1Y A1Inh6nyXaD9BYrl+MBw4Wg0SLPXn0k2JB/Q9fcyOIzuArJyNP5CAP/OYrRz9t8OjR5S XFCXOEj9gTBCbRp0ivB+ptHleUzLXnVgoJHfkSbeUIp235ARs0kM3FqWAyKPVdj8EdIY g3RKR4XkBKUHEpM9jNFnZxevC48Iohvuk0cmtfkiBYMai53Lu8l/dDh2BwsLdy9gFHvA QWc11/u2heT18aU8rRo5fdtj59mvSyZm/BWooWabxZinM16J0LTQ5ey53DnbRa6Ouc8K cXTA== X-Gm-Message-State: AOAM532Ik35tQNF5jy9tqnKtejJDXsxzbLsAYeHEFKO9jXLCEh+HSbTk kgPaPllrnjwHjaJd5z6qYJL1vmN+XUrarrtlRxP4xKxl3S1mvkZh X-Google-Smtp-Source: ABdhPJwNTA32kbg4lIZb9ARiNdffw3OZkM9jtgokU772uYccGqloCbR80JfnIoOPeAt0wl/cyFwiKECTBElHgzd3SLQ= X-Received: by 2002:a17:906:1945:: with SMTP id b5mr5080282eje.102.1600193399482; Tue, 15 Sep 2020 11:09:59 -0700 (PDT) MIME-Version: 1.0 References: <68dc1ea1-52e8-7d9e-fb2d-bcf08c111eca@intrepidus.pl> <87d02n2yyr.fsf@gmail.com> <482cea5c-4214-57ac-dfeb-1e305180fee5@intrepidus.pl> <20200915095548.GP20869@maokai> <20200915123722.GA20532@tuxteam.de> In-Reply-To: <20200915123722.GA20532@tuxteam.de> From: Diego Zamboni Date: Tue, 15 Sep 2020 20:09:48 +0200 Message-ID: Subject: Re: official orgmode parser To: tomas@tuxteam.de Content-Type: multipart/alternative; boundary="00000000000026133605af5e0f22" Received-SPF: none client-ip=2a00:1450:4864:20::636; envelope-from=diego@zzamboni.org; helo=mail-ej1-x636.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: =?UTF-8?B?UHJ6ZW15c8WCYXcgS2FtacWEc2tp?= , Org-mode Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=zzamboni-org.20150623.gappssmtp.com header.s=20150623 header.b=ruqawdYb; 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-Spam-Score: -0.21 X-TUID: r0gyRDxQ4+fc --00000000000026133605af5e0f22 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable There's also org-ql (https://github.com/alphapapa/org-ql), which also provides a query-based API against Org structures. --Diego On Tue, Sep 15, 2020 at 2:59 PM wrote: > On Tue, Sep 15, 2020 at 01:15:56PM +0200, Przemys=C5=82aw Kami=C5=84ski w= rote: > > [...] > > > There's the org-json (or ox-json) package but for some reason I > > wasn't able to run it successfully. I guess export to S-exps would > > be best here. But yes I'll check that out. > > If that's your route, perhaps the "Org element API" [1] might be > helpful. Especially `org-element-parse-buffer' gives you a Lisp > data structure which is supposed to be a parse of your Org buffer. > > From there to S-expression can be trivial (e.g. `print' or `pp'), > depending on what you want to do. > > Walking the structure should be nice in Lisp, too. > > The topic of (non-Emacs) parsing of Org comes up regularly, and > there is a good (but AFAIK not-quite-complete) Org syntax spec > in Worg [2], but there are a couple of difficulties to be mastered > before such a thing can become really enjoyable and useful. > > The loose specification of Org's format (arguably its second > or third strongest asset, the first two being its incredible > community and Emacs itself) is something which makes this > problem "interesting". People have invented lots of usages > which might be broken should Org change to a strict formal > spec. You don't want to break those people. > > But yes, perhaps some day someone nails it. Perhaps it's you :) > > Cheers > > [1] https://orgmode.org/worg/dev/org-element-api.html > [2] https://orgmode.org/worg/dev/org-syntax.html > > - t > --00000000000026133605af5e0f22 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
There's also org-ql (https://github.com/alphapapa/org-ql), which also provide= s a query-based API against Org structures.

--Diego


On Tue, Sep 15, 2020 at 2:59 PM <tomas@tuxteam.de> wrote:
On Tue, Sep 15, 2020 at 01:15:56PM +0200, Prze= mys=C5=82aw Kami=C5=84ski wrote:

[...]

> There's the org-json (or ox-json) package but for some reason I > wasn't able to run it successfully. I guess export to S-exps would=
> be best here. But yes I'll check that out.

If that's your route, perhaps the "Org element API" [1] might= be
helpful. Especially `org-element-parse-buffer' gives you a Lisp
data structure which is supposed to be a parse of your Org buffer.

>From there to S-expression can be trivial (e.g. `print' or `pp'), depending on what you want to do.

Walking the structure should be nice in Lisp, too.

The topic of (non-Emacs) parsing of Org comes up regularly, and
there is a good (but AFAIK not-quite-complete) Org syntax spec
in Worg [2], but there are a couple of difficulties to be mastered
before such a thing can become really enjoyable and useful.

The loose specification of Org's format (arguably its second
or third strongest asset, the first two being its incredible
community and Emacs itself) is something which makes this
problem "interesting". People have invented lots of usages
which might be broken should Org change to a strict formal
spec. You don't want to break those people.

But yes, perhaps some day someone nails it. Perhaps it's you :)

Cheers

[1] https://orgmode.org/worg/dev/org-element-api.ht= ml
[2] https://orgmode.org/worg/dev/org-syntax.html

=C2=A0- t
--00000000000026133605af5e0f22--