From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/33144 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Albert Krewinkel Newsgroups: gmane.text.pandoc Subject: Re: Markdown in JSON (was: Parse metadata in defaults files as Markdown?) Date: Mon, 02 Oct 2023 21:08:36 +0200 Message-ID: <87edicolz7.fsf@zeitkraut.de> References: <87r0mgof6d.fsf@zeitkraut.de> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32951"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBCZJF7XJTILRBQVX5SUAMGQEO25RN5Q-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mon Oct 02 21:36:41 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-wr1-f61.google.com ([209.85.221.61]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1qnOid-000839-2H for gtp-pandoc-discuss@m.gmane-mx.org; Mon, 02 Oct 2023 21:36:39 +0200 Original-Received: by mail-wr1-f61.google.com with SMTP id ffacd0b85a97d-3232c3df248sf102491f8f.3 for ; Mon, 02 Oct 2023 12:36:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1696275398; cv=pass; d=google.com; s=arc-20160816; b=EIUMzDKJi14+J64VLsp+Z3PPgO+f24r/dVyzjAjEZxlCZFFz78/YB0JLPR6YNndg4W dakIJ37h9G/W8MVoSHHom0VvBdTBQKPN+9NLJf8izT+A7J3KfqxdsQPBo7+N2mge2FmC Ipz1XxGOt2E29cite02AW5YENplXZfGybqsKhxS2Kn8Clxb5fRQ+SjuDOxsUos49y53f dk5RCIaSlyqk5fYE7EEBMuq5DsWCGHv3z1yE/ehSjxiWhizwIwJ50OAvYnrRVXn1z1RP TzWwq8juWDM/LHg9rps29sIW0m3ZrVb9YoPKeW8Nfm3qUtaSJmQemeL73diXsltzkoPV ifCg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:mime-version:message-id :in-reply-to:date:subject:to:from:references:sender:dkim-signature; bh=eqQkB1pDTka3Ulj74VrbxHf24hPTmCQE4g6NauFmuEw=; fh=m01AhCNo7xUywHldCVYouaJypLlN7JgtNYbImzBf4N4=; b=gZ8KupThjcnJ7SrxMqYrPSpcLy9bN3ewzVKwv+2tJAUjR4dGzNfwEd2GIkhn0ZyYwq c1bT+yxfwhHlV8yFu834ItBlY/ShBW657ZL6ryHLx6X/qPv5C7OtMOCHoUo7lcShujMQ yJvJDilZr0+4sCUOXXhwdiILELbpAthe7Zh54MbzTnzOAsRR7MDDg7ThKe4JtJpHOfs9 VBWbXG9L2WfOjiIzeWK4EiCG1WRrHpvM0ciq9hNtxa8VEq2dfTVpM7sZneE95O9rzWuh xOdbeX6GctjsiBqLLE3F6MkebWf8caYEBsWglNrMPY/Y1gsVdybARxFwebzqGlX9czPj x+4Q== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 80.241.56.151 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1696275398; x=1696880198; darn=m.gmane-mx.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:mime-version :message-id:in-reply-to:date:subject:to:from:references:sender:from :to:cc:subject:date:message-id:reply-to; bh=eqQkB1pDTka3Ulj74VrbxHf24hPTmCQE4g6NauFmuEw=; b=nU7tO4a19QWyo5cgvmWdyrM0jdz6lhGTP4Y1sDRTJPkt5kv8fae71eDKmAnpgDLNVC KPFbBG4SwObTOSleqsoli4NTp9+LgNA0JuexmPUoOwFM1UQgBEAe5lCBX/F9TAbo3i6s 58q2d7oPlnDltpqiiewibpXvhz10yK+xkygeHBcaJuCrtimqhwBiO7c/bnBQ6OzO00N3 PVB7dZ27gBPVEQmwDt39G35kh+s4Muv9frkgpK8exe9aUY6ZwgCjww1c0SyTcT29BB7A mzEqjy9Dx8++i62CGFwjCNT2HQfyFqCul8Fier6sZ/5BUfWU42x0 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696275398; x=1696880198; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:mime-version :message-id:in-reply-to:date:subject:to:from:references:x-beenthere :x-gm-message-state:sender:from:to:cc:subject:date:message-id :reply-to; bh=eqQkB1pDTka3Ulj74VrbxHf24hPTmCQE4g6NauFmuEw=; b=KsLpvxcB3JPDo8tSuWda02kpd+1JOkNJmuoEjxkLriqc26GddlwIo6NE8ztP7Ru+9d QxV+yh2AFm5IaubvSv1uTaYNfffuOWYGrAJqsPFBUiL0zvqzl0gMjW6r+N5+mRfR73v+ GPt1HRxM+IAFCbulbX2CopNvzeWk+ZWBtjb/WEwx4hur/N2PhSS9XBhNCVX9Q/y4G1oL 67v5+KiMM7eu3PDDw5gZaB5oJ0C5Gqd0Vt2sMWAft1Lu8q4G5i6U3VQ+jsF3CH+Is+Ap ehpWcr Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOJu0YzTi+gY9Bh9Nt4LUco6wq2ZDN3fwXGtacVclNhRHkcWmrY+8Gw+ xMuvYpL3VNNRihpmQ7FOZGs= X-Google-Smtp-Source: AGHT+IG8ZncA/O/kwSH6RPOD5nZLzjdChfu79wMIOwqiEINbucwG32cBsOLMdIYnhhmnd8ywi7YQsA== X-Received: by 2002:adf:e38e:0:b0:31f:afeb:4e7e with SMTP id e14-20020adfe38e000000b0031fafeb4e7emr9569203wrm.37.1696275398148; Mon, 02 Oct 2023 12:36:38 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6000:92b:b0:323:3654:7d7d with SMTP id cx11-20020a056000092b00b0032336547d7dls60265wrb.2.-pod-prod-03-eu; Mon, 02 Oct 2023 12:36:32 -0700 (PDT) X-Received: by 2002:a5d:500b:0:b0:319:6d03:13ae with SMTP id e11-20020a5d500b000000b003196d0313aemr10349614wrt.55.1696275392235; Mon, 02 Oct 2023 12:36:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696275392; cv=none; d=google.com; s=arc-20160816; b=i5sC6KcSfZYGcZeP4SC4tliMSU362XrmRUD6p76G8nUpGpo1CAcwjDfw5b9szo98/y 0aRXmaTaEBXJaiX9XOabt3NEDvDXgqHJi1wr8gBTnjMIPuS4bGvempS6KNprwH7o0SrU UpuE41fkehbbbCdMRqHQ/F7h6H73/Q1d5n9AB970g6O6HWKUpvMEASoFP075aeuLZiyJ EZJaBcc6MXcQWDji4u3hNY6SxR10AnqpJoYiTkuR2NyA/FUht8zX5sK0hOCBtsBNbE1U FKaZF0XAVZLC1w1IiPGoDGIIldDqGmzpfrj6KQHMXuryc8+FGuqitqnCTuob9oGU3KMJ 9gAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:message-id:in-reply-to:date:subject:to:from:references; bh=4fQ2Y0YiddsANpEARueLgPOLf2dBu3/EFC+usC6uPWo=; fh=m01AhCNo7xUywHldCVYouaJypLlN7JgtNYbImzBf4N4=; b=eFoR7fwGbk2GEjI0Ht6OiiwWeKaQYZB8EwkZu12YmKSH8C99vC/ACWEB5UkxN8nbYc ZE90kZHmNOtMrqSjzOy8wO3//ysL9uU01Xa9X7IBkzVfJanOPMbfe95NybA8iZd4349f czpkRCP1YLC8zz9soiuUK/HV/nRL+hif1PrmJ3ASvUWLYOMvY1s12diQa0sBthkXJ6NE 3Cy6xzxU4KAE2cCu4ZPS+4hnOLolroKGhCOHSSGLkSmwTuDbKAeBc4TM3BVdBfWW4D0r TDgZt8XlcPAUQ8vNvbbIywmV1JlKrRv/zK+VjM92EipK/36+LI5O6et+FdlgmcOO+15R FBBA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 80.241.56.151 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org Original-Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org. [80.241.56.151]) by gmr-mx.google.com with ESMTPS id bo9-20020a056000068900b00317e1e2b28asi1759424wrb.4.2023.10.02.12.36.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 12:36:32 -0700 (PDT) Received-SPF: pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 80.241.56.151 as permitted sender) client-ip=80.241.56.151; Original-Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4RzrmY5yyLz9sR8 for ; Mon, 2 Oct 2023 21:36:29 +0200 (CEST) In-reply-to: X-Rspamd-Queue-Id: 4RzrmY5yyLz9sR8 X-Original-Sender: albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 80.241.56.151 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:33144 Archived-At: BPJ writes: > how and when does `pandoc.json.decode()` parse its argument into AST > elements? Decoding to AST elements if possible is the default, but that can be disabled by passing `false` as the second argument: > pandoc.json.decode('{"t":"Str", "c":"Hello"}') Str "Hello" > type(pandoc.json.decode('{"t":"Str", "c":"Hello"}')) userdata > pandoc.json.decode('{"t":"Str", "c":"Hello"}', false) table: 0xc742c60 > type(pandoc.json.decode('{"t":"Str", "c":"Hello"}', false)) table The "how" is rather simple: the function tries to parse the input as Inline, Block, Pandoc, Inlines, and Blocks, in that order. If one of those attempts succeeds, then the respective AST element is returned. Otherwise it falls back to returning the value as a plain Lua object. -- Albert Krewinkel GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124